@mapgis/mapbox-gl 16.0.0 → 16.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/dist/mapbox-gl.js +4 -4
  2. package/dist/mapbox-gl.js.map +1 -1
  3. package/package.json +4 -5
  4. package/.flowconfig +0 -61
  5. package/LICENSE.txt +0 -84
  6. package/README.md +0 -34
  7. package/build/banner.js +0 -4
  8. package/build/check-bundle-size.js +0 -140
  9. package/build/generate-access-token-script.js +0 -11
  10. package/build/generate-flow-typed-style-spec.js +0 -188
  11. package/build/generate-release-list.js +0 -21
  12. package/build/generate-struct-arrays.js +0 -237
  13. package/build/generate-style-code.js +0 -159
  14. package/build/mapbox-gl.js.flow +0 -3
  15. package/build/print-release-url.js +0 -6
  16. package/build/rollup_plugin_minify_style_spec.js +0 -20
  17. package/build/rollup_plugins.js +0 -80
  18. package/build/run-node +0 -3
  19. package/build/run-tap +0 -8
  20. package/build/test/build-tape.js +0 -19
  21. package/dist/mapbox-gl-csp-worker.js +0 -2
  22. package/dist/mapbox-gl-csp-worker.js.map +0 -1
  23. package/dist/mapbox-gl-csp.js +0 -2
  24. package/dist/mapbox-gl-csp.js.map +0 -1
  25. package/dist/mapbox-gl-dev.js +0 -68798
  26. package/dist/mapbox-gl-unminified.js +0 -45076
  27. package/dist/mapbox-gl-unminified.js.map +0 -1
  28. package/flow-typed/gl.js +0 -5
  29. package/flow-typed/jsdom.js +0 -18
  30. package/flow-typed/mapbox-gl-supported.js +0 -9
  31. package/flow-typed/mapbox-unitbezier.js +0 -14
  32. package/flow-typed/offscreen-canvas.js +0 -9
  33. package/flow-typed/pbf.js +0 -25
  34. package/flow-typed/point-geometry.js +0 -44
  35. package/flow-typed/potpack.js +0 -12
  36. package/flow-typed/sinon.js +0 -28
  37. package/flow-typed/vector-tile.js +0 -41
  38. package/src/css/mapbox-gl.css +0 -798
  39. package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
  40. package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
  41. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
  42. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
  43. package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
  44. package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
  45. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
  46. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
  47. package/src/data/array_types.js +0 -1095
  48. package/src/data/bucket/circle_attributes.js +0 -9
  49. package/src/data/bucket/circle_bucket.js +0 -204
  50. package/src/data/bucket/fill_attributes.js +0 -9
  51. package/src/data/bucket/fill_bucket.js +0 -233
  52. package/src/data/bucket/fill_extrusion_attributes.js +0 -10
  53. package/src/data/bucket/fill_extrusion_bucket.js +0 -289
  54. package/src/data/bucket/heatmap_bucket.js +0 -17
  55. package/src/data/bucket/line_attributes.js +0 -10
  56. package/src/data/bucket/line_bucket.js +0 -556
  57. package/src/data/bucket/pattern_attributes.js +0 -10
  58. package/src/data/bucket/pattern_bucket_features.js +0 -60
  59. package/src/data/bucket/symbol_attributes.js +0 -117
  60. package/src/data/bucket/symbol_bucket.js +0 -972
  61. package/src/data/bucket.js +0 -123
  62. package/src/data/dem_data.js +0 -125
  63. package/src/data/extent.js +0 -18
  64. package/src/data/feature_index.js +0 -321
  65. package/src/data/feature_position_map.js +0 -125
  66. package/src/data/index_array_type.js +0 -16
  67. package/src/data/load_geometry.js +0 -48
  68. package/src/data/pos_attributes.js +0 -6
  69. package/src/data/program_configuration.js +0 -687
  70. package/src/data/raster_bounds_attributes.js +0 -7
  71. package/src/data/segment.js +0 -76
  72. package/src/geo/edge_insets.js +0 -102
  73. package/src/geo/lng_lat.js +0 -165
  74. package/src/geo/lng_lat_bounds.js +0 -267
  75. package/src/geo/mercator_coordinate.js +0 -153
  76. package/src/geo/transform.js +0 -864
  77. package/src/gl/color_mode.js +0 -34
  78. package/src/gl/context.js +0 -298
  79. package/src/gl/cull_face_mode.js +0 -26
  80. package/src/gl/depth_mode.js +0 -29
  81. package/src/gl/framebuffer.js +0 -44
  82. package/src/gl/index_buffer.js +0 -55
  83. package/src/gl/stencil_mode.js +0 -30
  84. package/src/gl/types.js +0 -84
  85. package/src/gl/value.js +0 -520
  86. package/src/gl/vertex_buffer.js +0 -119
  87. package/src/index.js +0 -201
  88. package/src/render/draw_background.js +0 -57
  89. package/src/render/draw_circle.js +0 -113
  90. package/src/render/draw_collision_debug.js +0 -49
  91. package/src/render/draw_custom.js +0 -49
  92. package/src/render/draw_debug.js +0 -127
  93. package/src/render/draw_fill.js +0 -126
  94. package/src/render/draw_fill_extrusion.js +0 -96
  95. package/src/render/draw_heatmap.js +0 -140
  96. package/src/render/draw_hillshade.js +0 -108
  97. package/src/render/draw_line.js +0 -98
  98. package/src/render/draw_raster.js +0 -125
  99. package/src/render/draw_symbol.js +0 -394
  100. package/src/render/glyph_atlas.js +0 -71
  101. package/src/render/glyph_manager.js +0 -182
  102. package/src/render/image_atlas.js +0 -149
  103. package/src/render/image_manager.js +0 -306
  104. package/src/render/line_atlas.js +0 -210
  105. package/src/render/painter.js +0 -653
  106. package/src/render/program/background_program.js +0 -103
  107. package/src/render/program/circle_program.js +0 -69
  108. package/src/render/program/clipping_mask_program.js +0 -20
  109. package/src/render/program/collision_program.js +0 -49
  110. package/src/render/program/debug_program.js +0 -35
  111. package/src/render/program/fill_extrusion_program.js +0 -122
  112. package/src/render/program/fill_program.js +0 -126
  113. package/src/render/program/heatmap_program.js +0 -83
  114. package/src/render/program/hillshade_program.js +0 -122
  115. package/src/render/program/line_program.js +0 -207
  116. package/src/render/program/pattern.js +0 -102
  117. package/src/render/program/program_uniforms.js +0 -42
  118. package/src/render/program/raster_program.js +0 -92
  119. package/src/render/program/symbol_program.js +0 -224
  120. package/src/render/program.js +0 -168
  121. package/src/render/texture.js +0 -122
  122. package/src/render/uniform_binding.js +0 -147
  123. package/src/render/vertex_array_object.js +0 -163
  124. package/src/shaders/README.md +0 -42
  125. package/src/shaders/_prelude.fragment.glsl +0 -17
  126. package/src/shaders/_prelude.vertex.glsl +0 -73
  127. package/src/shaders/background.fragment.glsl +0 -10
  128. package/src/shaders/background.vertex.glsl +0 -7
  129. package/src/shaders/background_pattern.fragment.glsl +0 -28
  130. package/src/shaders/background_pattern.vertex.glsl +0 -20
  131. package/src/shaders/circle.fragment.glsl +0 -39
  132. package/src/shaders/circle.vertex.glsl +0 -64
  133. package/src/shaders/clipping_mask.fragment.glsl +0 -3
  134. package/src/shaders/clipping_mask.vertex.glsl +0 -7
  135. package/src/shaders/collision_box.fragment.glsl +0 -21
  136. package/src/shaders/collision_box.vertex.glsl +0 -27
  137. package/src/shaders/collision_circle.fragment.glsl +0 -34
  138. package/src/shaders/collision_circle.vertex.glsl +0 -36
  139. package/src/shaders/debug.fragment.glsl +0 -9
  140. package/src/shaders/debug.vertex.glsl +0 -12
  141. package/src/shaders/encode_attribute.js +0 -17
  142. package/src/shaders/fill.fragment.glsl +0 -13
  143. package/src/shaders/fill.vertex.glsl +0 -13
  144. package/src/shaders/fill_extrusion.fragment.glsl +0 -9
  145. package/src/shaders/fill_extrusion.vertex.glsl +0 -66
  146. package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
  147. package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
  148. package/src/shaders/fill_outline.fragment.glsl +0 -17
  149. package/src/shaders/fill_outline.vertex.glsl +0 -17
  150. package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
  151. package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
  152. package/src/shaders/fill_pattern.fragment.glsl +0 -36
  153. package/src/shaders/fill_pattern.vertex.glsl +0 -39
  154. package/src/shaders/heatmap.fragment.glsl +0 -22
  155. package/src/shaders/heatmap.vertex.glsl +0 -54
  156. package/src/shaders/heatmap_texture.fragment.glsl +0 -14
  157. package/src/shaders/heatmap_texture.vertex.glsl +0 -11
  158. package/src/shaders/hillshade.fragment.glsl +0 -52
  159. package/src/shaders/hillshade.vertex.glsl +0 -11
  160. package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
  161. package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
  162. package/src/shaders/index.js +0 -20
  163. package/src/shaders/line.fragment.glsl +0 -30
  164. package/src/shaders/line.vertex.glsl +0 -85
  165. package/src/shaders/line_gradient.fragment.glsl +0 -34
  166. package/src/shaders/line_gradient.vertex.glsl +0 -87
  167. package/src/shaders/line_pattern.fragment.glsl +0 -74
  168. package/src/shaders/line_pattern.vertex.glsl +0 -99
  169. package/src/shaders/line_sdf.fragment.glsl +0 -45
  170. package/src/shaders/line_sdf.vertex.glsl +0 -98
  171. package/src/shaders/raster.fragment.glsl +0 -52
  172. package/src/shaders/raster.vertex.glsl +0 -21
  173. package/src/shaders/shaders.js +0 -180
  174. package/src/shaders/symbol_icon.fragment.glsl +0 -17
  175. package/src/shaders/symbol_icon.vertex.glsl +0 -94
  176. package/src/shaders/symbol_sdf.fragment.glsl +0 -52
  177. package/src/shaders/symbol_sdf.vertex.glsl +0 -115
  178. package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
  179. package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
  180. package/src/source/canvas_source.js +0 -238
  181. package/src/source/geojson_helper.js +0 -92
  182. package/src/source/geojson_source.js +0 -374
  183. package/src/source/geojson_worker_source.js +0 -357
  184. package/src/source/geojson_wrapper.js +0 -94
  185. package/src/source/image_source.js +0 -307
  186. package/src/source/load_tilejson.js +0 -39
  187. package/src/source/mbtiles_source.js +0 -115
  188. package/src/source/offline_database.js +0 -61
  189. package/src/source/offline_database_root.js +0 -62
  190. package/src/source/pixels_to_tile_units.js +0 -21
  191. package/src/source/query_features.js +0 -208
  192. package/src/source/raster_dem_tile_source.js +0 -138
  193. package/src/source/raster_dem_tile_worker_source.js +0 -62
  194. package/src/source/raster_tile_offline_source.js +0 -136
  195. package/src/source/raster_tile_source.js +0 -177
  196. package/src/source/rtl_text_plugin.js +0 -138
  197. package/src/source/source.js +0 -137
  198. package/src/source/source_cache.js +0 -957
  199. package/src/source/source_state.js +0 -159
  200. package/src/source/tile.js +0 -465
  201. package/src/source/tile_bounds.js +0 -38
  202. package/src/source/tile_cache.js +0 -212
  203. package/src/source/tile_id.js +0 -402
  204. package/src/source/vector_tile_source.js +0 -192
  205. package/src/source/vector_tile_worker_source.js +0 -216
  206. package/src/source/video_source.js +0 -203
  207. package/src/source/worker.js +0 -237
  208. package/src/source/worker_source.js +0 -106
  209. package/src/source/worker_tile.js +0 -224
  210. package/src/style/create_style_layer.js +0 -36
  211. package/src/style/evaluation_parameters.js +0 -62
  212. package/src/style/light.js +0 -130
  213. package/src/style/load_glyph_range.js +0 -38
  214. package/src/style/load_sprite.js +0 -67
  215. package/src/style/parse_glyph_pbf.js +0 -44
  216. package/src/style/pauseable_placement.js +0 -132
  217. package/src/style/properties.js +0 -753
  218. package/src/style/query_utils.js +0 -43
  219. package/src/style/style.js +0 -1361
  220. package/src/style/style_glyph.js +0 -17
  221. package/src/style/style_image.js +0 -137
  222. package/src/style/style_layer/background_style_layer.js +0 -21
  223. package/src/style/style_layer/background_style_layer_properties.js +0 -40
  224. package/src/style/style_layer/circle_style_layer.js +0 -98
  225. package/src/style/style_layer/circle_style_layer_properties.js +0 -63
  226. package/src/style/style_layer/custom_style_layer.js +0 -223
  227. package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
  228. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
  229. package/src/style/style_layer/fill_style_layer.js +0 -67
  230. package/src/style/style_layer/fill_style_layer_properties.js +0 -55
  231. package/src/style/style_layer/heatmap_style_layer.js +0 -69
  232. package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
  233. package/src/style/style_layer/hillshade_style_layer.js +0 -25
  234. package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
  235. package/src/style/style_layer/layer_properties.js.ejs +0 -69
  236. package/src/style/style_layer/line_style_layer.js +0 -151
  237. package/src/style/style_layer/line_style_layer_properties.js +0 -71
  238. package/src/style/style_layer/raster_style_layer.js +0 -21
  239. package/src/style/style_layer/raster_style_layer_properties.js +0 -50
  240. package/src/style/style_layer/symbol_style_layer.js +0 -190
  241. package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
  242. package/src/style/style_layer/typed_style_layer.js +0 -17
  243. package/src/style/style_layer.js +0 -281
  244. package/src/style/style_layer_index.js +0 -80
  245. package/src/style/validate_style.js +0 -42
  246. package/src/style/zoom_history.js +0 -44
  247. package/src/style-spec/.eslintrc +0 -5
  248. package/src/style-spec/CHANGELOG.md +0 -438
  249. package/src/style-spec/README.md +0 -59
  250. package/src/style-spec/bin/gl-style-composite +0 -9
  251. package/src/style-spec/bin/gl-style-format +0 -22
  252. package/src/style-spec/bin/gl-style-migrate +0 -9
  253. package/src/style-spec/bin/gl-style-validate +0 -50
  254. package/src/style-spec/composite.js +0 -50
  255. package/src/style-spec/declass.js +0 -42
  256. package/src/style-spec/deref.js +0 -52
  257. package/src/style-spec/diff.js +0 -393
  258. package/src/style-spec/dist/.gitkeep +0 -0
  259. package/src/style-spec/empty.js +0 -29
  260. package/src/style-spec/error/parsing_error.js +0 -16
  261. package/src/style-spec/error/validation_error.js +0 -18
  262. package/src/style-spec/expression/compound_expression.js +0 -162
  263. package/src/style-spec/expression/definitions/assertion.js +0 -130
  264. package/src/style-spec/expression/definitions/at.js +0 -70
  265. package/src/style-spec/expression/definitions/case.js +0 -85
  266. package/src/style-spec/expression/definitions/coalesce.js +0 -93
  267. package/src/style-spec/expression/definitions/coercion.js +0 -133
  268. package/src/style-spec/expression/definitions/collator.js +0 -78
  269. package/src/style-spec/expression/definitions/comparison.js +0 -184
  270. package/src/style-spec/expression/definitions/format.js +0 -144
  271. package/src/style-spec/expression/definitions/format_section_override.js +0 -54
  272. package/src/style-spec/expression/definitions/image.js +0 -52
  273. package/src/style-spec/expression/definitions/in.js +0 -92
  274. package/src/style-spec/expression/definitions/index.js +0 -561
  275. package/src/style-spec/expression/definitions/interpolate.js +0 -267
  276. package/src/style-spec/expression/definitions/length.js +0 -61
  277. package/src/style-spec/expression/definitions/let.js +0 -72
  278. package/src/style-spec/expression/definitions/literal.js +0 -77
  279. package/src/style-spec/expression/definitions/match.js +0 -158
  280. package/src/style-spec/expression/definitions/number_format.js +0 -142
  281. package/src/style-spec/expression/definitions/step.js +0 -120
  282. package/src/style-spec/expression/definitions/var.js +0 -46
  283. package/src/style-spec/expression/definitions/within.js +0 -333
  284. package/src/style-spec/expression/evaluation_context.js +0 -59
  285. package/src/style-spec/expression/expression.js +0 -27
  286. package/src/style-spec/expression/index.js +0 -392
  287. package/src/style-spec/expression/is_constant.js +0 -59
  288. package/src/style-spec/expression/parsing_context.js +0 -233
  289. package/src/style-spec/expression/parsing_error.js +0 -13
  290. package/src/style-spec/expression/runtime_error.js +0 -17
  291. package/src/style-spec/expression/scope.js +0 -36
  292. package/src/style-spec/expression/stops.js +0 -39
  293. package/src/style-spec/expression/types/collator.js +0 -61
  294. package/src/style-spec/expression/types/formatted.js +0 -73
  295. package/src/style-spec/expression/types/resolved_image.js +0 -29
  296. package/src/style-spec/expression/types.js +0 -106
  297. package/src/style-spec/expression/values.js +0 -123
  298. package/src/style-spec/feature_filter/README.md +0 -55
  299. package/src/style-spec/feature_filter/convert.js +0 -208
  300. package/src/style-spec/feature_filter/index.js +0 -165
  301. package/src/style-spec/format.js +0 -51
  302. package/src/style-spec/function/convert.js +0 -254
  303. package/src/style-spec/function/index.js +0 -262
  304. package/src/style-spec/group_by_layout.js +0 -75
  305. package/src/style-spec/migrate/expressions.js +0 -39
  306. package/src/style-spec/migrate/v8.js +0 -203
  307. package/src/style-spec/migrate/v9.js +0 -26
  308. package/src/style-spec/migrate.js +0 -36
  309. package/src/style-spec/package.json +0 -41
  310. package/src/style-spec/read_style.js +0 -14
  311. package/src/style-spec/reference/latest.js +0 -3
  312. package/src/style-spec/reference/v8.json +0 -5808
  313. package/src/style-spec/rollup.config.js +0 -45
  314. package/src/style-spec/style-spec.js +0 -122
  315. package/src/style-spec/types.js +0 -438
  316. package/src/style-spec/util/color.js +0 -95
  317. package/src/style-spec/util/color_spaces.js +0 -139
  318. package/src/style-spec/util/deep_equal.js +0 -28
  319. package/src/style-spec/util/extend.js +0 -10
  320. package/src/style-spec/util/get_type.js +0 -17
  321. package/src/style-spec/util/interpolate.js +0 -22
  322. package/src/style-spec/util/properties.js +0 -15
  323. package/src/style-spec/util/ref_properties.js +0 -2
  324. package/src/style-spec/util/result.js +0 -19
  325. package/src/style-spec/util/unbundle_jsonlint.js +0 -24
  326. package/src/style-spec/validate/latest.js +0 -11
  327. package/src/style-spec/validate/validate.js +0 -75
  328. package/src/style-spec/validate/validate_array.js +0 -52
  329. package/src/style-spec/validate/validate_boolean.js +0 -15
  330. package/src/style-spec/validate/validate_color.js +0 -20
  331. package/src/style-spec/validate/validate_constants.js +0 -13
  332. package/src/style-spec/validate/validate_enum.js +0 -21
  333. package/src/style-spec/validate/validate_expression.js +0 -43
  334. package/src/style-spec/validate/validate_filter.js +0 -111
  335. package/src/style-spec/validate/validate_formatted.js +0 -11
  336. package/src/style-spec/validate/validate_function.js +0 -207
  337. package/src/style-spec/validate/validate_glyphs_url.js +0 -21
  338. package/src/style-spec/validate/validate_image.js +0 -11
  339. package/src/style-spec/validate/validate_layer.js +0 -134
  340. package/src/style-spec/validate/validate_layout_property.js +0 -6
  341. package/src/style-spec/validate/validate_light.js +0 -47
  342. package/src/style-spec/validate/validate_number.js +0 -29
  343. package/src/style-spec/validate/validate_object.js +0 -61
  344. package/src/style-spec/validate/validate_paint_property.js +0 -6
  345. package/src/style-spec/validate/validate_property.js +0 -64
  346. package/src/style-spec/validate/validate_source.js +0 -111
  347. package/src/style-spec/validate/validate_string.js +0 -15
  348. package/src/style-spec/validate_mapbox_api_supported.js +0 -171
  349. package/src/style-spec/validate_style.js +0 -39
  350. package/src/style-spec/validate_style.min.js +0 -78
  351. package/src/style-spec/visit.js +0 -77
  352. package/src/symbol/anchor.js +0 -26
  353. package/src/symbol/check_max_angle.js +0 -81
  354. package/src/symbol/clip_line.js +0 -71
  355. package/src/symbol/collision_feature.js +0 -217
  356. package/src/symbol/collision_index.js +0 -372
  357. package/src/symbol/cross_tile_symbol_index.js +0 -301
  358. package/src/symbol/get_anchors.js +0 -167
  359. package/src/symbol/grid_index.js +0 -335
  360. package/src/symbol/mergelines.js +0 -82
  361. package/src/symbol/one_em.js +0 -4
  362. package/src/symbol/opacity_state.js +0 -27
  363. package/src/symbol/placement.js +0 -1062
  364. package/src/symbol/projection.js +0 -450
  365. package/src/symbol/quads.js +0 -334
  366. package/src/symbol/shaping.js +0 -816
  367. package/src/symbol/symbol_layout.js +0 -772
  368. package/src/symbol/symbol_size.js +0 -113
  369. package/src/symbol/transform_text.js +0 -29
  370. package/src/types/callback.js +0 -17
  371. package/src/types/cancelable.js +0 -3
  372. package/src/types/tilejson.js +0 -17
  373. package/src/types/transferable.js +0 -3
  374. package/src/types/window.js +0 -172
  375. package/src/ui/anchor.js +0 -32
  376. package/src/ui/bind_handlers.js +0 -202
  377. package/src/ui/camera.js +0 -1152
  378. package/src/ui/control/attribution_control.js +0 -189
  379. package/src/ui/control/fps_control.js +0 -185
  380. package/src/ui/control/fullscreen_control.js +0 -147
  381. package/src/ui/control/geolocate_control.js +0 -594
  382. package/src/ui/control/logo_control.js +0 -92
  383. package/src/ui/control/navigation_control.js +0 -148
  384. package/src/ui/control/scale_control.js +0 -142
  385. package/src/ui/crs.js +0 -64
  386. package/src/ui/default_locale.js +0 -20
  387. package/src/ui/events.js +0 -806
  388. package/src/ui/handler/box_zoom.js +0 -175
  389. package/src/ui/handler/dblclick_zoom.js +0 -139
  390. package/src/ui/handler/drag_pan.js +0 -416
  391. package/src/ui/handler/drag_rotate.js +0 -378
  392. package/src/ui/handler/keyboard.js +0 -161
  393. package/src/ui/handler/scroll_zoom.js +0 -333
  394. package/src/ui/handler/touch_zoom_rotate.js +0 -293
  395. package/src/ui/hash.js +0 -147
  396. package/src/ui/map.js +0 -2883
  397. package/src/ui/marker.js +0 -607
  398. package/src/ui/offline_map.js +0 -91
  399. package/src/ui/popup.js +0 -530
  400. package/src/util/actor.js +0 -212
  401. package/src/util/ajax.js +0 -371
  402. package/src/util/browser/web_worker.js +0 -10
  403. package/src/util/browser/window.js +0 -5
  404. package/src/util/browser.js +0 -70
  405. package/src/util/classify_rings.js +0 -52
  406. package/src/util/color_ramp.js +0 -28
  407. package/src/util/config.js +0 -30
  408. package/src/util/debug.js +0 -12
  409. package/src/util/dictionary_coder.js +0 -30
  410. package/src/util/dispatcher.js +0 -70
  411. package/src/util/dom.js +0 -144
  412. package/src/util/evented.js +0 -174
  413. package/src/util/find_pole_of_inaccessibility.js +0 -129
  414. package/src/util/global_worker_pool.js +0 -17
  415. package/src/util/image.js +0 -142
  416. package/src/util/intersection_tests.js +0 -208
  417. package/src/util/is_char_in_unicode_block.js +0 -311
  418. package/src/util/mapbox.js +0 -486
  419. package/src/util/offscreen_canvas_supported.js +0 -14
  420. package/src/util/performance.js +0 -112
  421. package/src/util/primitives.js +0 -145
  422. package/src/util/resolve_tokens.js +0 -16
  423. package/src/util/script_detection.js +0 -328
  424. package/src/util/sku_token.js +0 -42
  425. package/src/util/smart_wrap.js +0 -55
  426. package/src/util/struct_array.js +0 -243
  427. package/src/util/struct_array.js.ejs +0 -112
  428. package/src/util/struct_array_layout.js.ejs +0 -98
  429. package/src/util/task_queue.js +0 -68
  430. package/src/util/throttle.js +0 -28
  431. package/src/util/throttled_invoker.js +0 -46
  432. package/src/util/tile_cover.js +0 -101
  433. package/src/util/tile_request_cache.js +0 -172
  434. package/src/util/util.js +0 -504
  435. package/src/util/vectortile_to_geojson.js +0 -54
  436. package/src/util/verticalize_punctuation.js +0 -114
  437. package/src/util/web_worker.js +0 -91
  438. package/src/util/web_worker_transfer.js +0 -266
  439. package/src/util/webp_supported.js +0 -69
  440. package/src/util/window.js +0 -102
  441. package/src/util/worker_pool.js +0 -47
@@ -1,1062 +0,0 @@
1
- // @flow
2
-
3
- import CollisionIndex from './collision_index';
4
- import EXTENT from '../data/extent';
5
- import * as symbolSize from './symbol_size';
6
- import * as projection from './projection';
7
- import {getAnchorJustification, evaluateVariableOffset} from './symbol_layout';
8
- import {getAnchorAlignment, WritingMode} from './shaping';
9
- import assert from 'assert';
10
- import pixelsToTileUnits from '../source/pixels_to_tile_units';
11
- import Point from '@mapbox/point-geometry';
12
- import type Transform from '../geo/transform';
13
- import type StyleLayer from '../style/style_layer';
14
-
15
- import type Tile from '../source/tile';
16
- import type SymbolBucket, {CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket';
17
- import type {mat4} from 'gl-matrix';
18
- import type {CollisionBoxArray, CollisionVertexArray, SymbolInstance} from '../data/array_types';
19
- import type FeatureIndex from '../data/feature_index';
20
- import type {OverscaledTileID} from '../source/tile_id';
21
- import type {TextAnchor} from './symbol_layout';
22
-
23
- class OpacityState {
24
- opacity: number;
25
- placed: boolean;
26
- constructor(prevState: ?OpacityState, increment: number, placed: boolean, skipFade: ?boolean) {
27
- if (prevState) {
28
- this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment)));
29
- } else {
30
- this.opacity = (skipFade && placed) ? 1 : 0;
31
- }
32
- this.placed = placed;
33
- }
34
- isHidden() {
35
- return this.opacity === 0 && !this.placed;
36
- }
37
- }
38
-
39
- class JointOpacityState {
40
- text: OpacityState;
41
- icon: OpacityState;
42
- constructor(prevState: ?JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade: ?boolean) {
43
- this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade);
44
- this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade);
45
- }
46
- isHidden() {
47
- return this.text.isHidden() && this.icon.isHidden();
48
- }
49
- }
50
-
51
- class JointPlacement {
52
- text: boolean;
53
- icon: boolean;
54
- // skipFade = outside viewport, but within CollisionIndex::viewportPadding px of the edge
55
- // Because these symbols aren't onscreen yet, we can skip the "fade in" animation,
56
- // and if a subsequent viewport change brings them into view, they'll be fully
57
- // visible right away.
58
- skipFade: boolean;
59
- constructor(text: boolean, icon: boolean, skipFade: boolean) {
60
- this.text = text;
61
- this.icon = icon;
62
- this.skipFade = skipFade;
63
- }
64
- }
65
-
66
- export class RetainedQueryData {
67
- bucketInstanceId: number;
68
- featureIndex: FeatureIndex;
69
- sourceLayerIndex: number;
70
- bucketIndex: number;
71
- tileID: OverscaledTileID;
72
- featureSortOrder: ?Array<number>
73
- constructor(bucketInstanceId: number,
74
- featureIndex: FeatureIndex,
75
- sourceLayerIndex: number,
76
- bucketIndex: number,
77
- tileID: OverscaledTileID) {
78
- this.bucketInstanceId = bucketInstanceId;
79
- this.featureIndex = featureIndex;
80
- this.sourceLayerIndex = sourceLayerIndex;
81
- this.bucketIndex = bucketIndex;
82
- this.tileID = tileID;
83
- }
84
- }
85
-
86
- type CollisionGroup = { ID: number, predicate?: any };
87
-
88
- class CollisionGroups {
89
- collisionGroups: {[groupName: string]: CollisionGroup};
90
- maxGroupID: number;
91
- crossSourceCollisions: boolean;
92
-
93
- constructor(crossSourceCollisions: boolean) {
94
- this.crossSourceCollisions = crossSourceCollisions;
95
- this.maxGroupID = 0;
96
- this.collisionGroups = {};
97
- }
98
-
99
- get(sourceID: string) {
100
- // The predicate/groupID mechanism allows for arbitrary grouping,
101
- // but the current interface defines one source == one group when
102
- // crossSourceCollisions == true.
103
- if (!this.crossSourceCollisions) {
104
- if (!this.collisionGroups[sourceID]) {
105
- const nextGroupID = ++this.maxGroupID;
106
- this.collisionGroups[sourceID] = {
107
- ID: nextGroupID,
108
- predicate: (key) => {
109
- return key.collisionGroupID === nextGroupID;
110
- }
111
- };
112
- }
113
- return this.collisionGroups[sourceID];
114
- } else {
115
- return {ID: 0, predicate: null};
116
- }
117
- }
118
- }
119
-
120
- function calculateVariableLayoutShift(anchor: TextAnchor, width: number, height: number, textOffset: [number, number], textBoxScale: number): Point {
121
- const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);
122
- const shiftX = -(horizontalAlign - 0.5) * width;
123
- const shiftY = -(verticalAlign - 0.5) * height;
124
- const offset = evaluateVariableOffset(anchor, textOffset);
125
- return new Point(
126
- shiftX + offset[0] * textBoxScale,
127
- shiftY + offset[1] * textBoxScale
128
- );
129
- }
130
-
131
- function shiftVariableCollisionBox(collisionBox: SingleCollisionBox,
132
- shiftX: number, shiftY: number,
133
- rotateWithMap: boolean, pitchWithMap: boolean,
134
- angle: number) {
135
- const {x1, x2, y1, y2, anchorPointX, anchorPointY} = collisionBox;
136
- const rotatedOffset = new Point(shiftX, shiftY);
137
- if (rotateWithMap) {
138
- rotatedOffset._rotate(pitchWithMap ? angle : -angle);
139
- }
140
- return {
141
- x1: x1 + rotatedOffset.x,
142
- y1: y1 + rotatedOffset.y,
143
- x2: x2 + rotatedOffset.x,
144
- y2: y2 + rotatedOffset.y,
145
- // symbol anchor point stays the same regardless of text-anchor
146
- anchorPointX,
147
- anchorPointY
148
- };
149
- }
150
-
151
- export type VariableOffset = {
152
- textOffset: [number, number],
153
- width: number,
154
- height: number,
155
- anchor: TextAnchor,
156
- textBoxScale: number,
157
- prevAnchor?: TextAnchor
158
- };
159
-
160
- type TileLayerParameters = {
161
- bucket: SymbolBucket,
162
- layout: any,
163
- posMatrix: mat4,
164
- textLabelPlaneMatrix: mat4,
165
- scale: number,
166
- textPixelRatio: number,
167
- holdingForFade: boolean,
168
- collisionBoxArray: ?CollisionBoxArray,
169
- partiallyEvaluatedTextSize: any,
170
- collisionGroup: any
171
- };
172
-
173
- export type BucketPart = {
174
- sortKey?: number | void,
175
- symbolInstanceStart: number,
176
- symbolInstanceEnd: number,
177
- parameters: TileLayerParameters
178
- };
179
-
180
- export type CrossTileID = string | number;
181
-
182
- export class Placement {
183
- transform: Transform;
184
- collisionIndex: CollisionIndex;
185
- placements: { [_: CrossTileID]: JointPlacement };
186
- opacities: { [_: CrossTileID]: JointOpacityState };
187
- variableOffsets: {[_: CrossTileID]: VariableOffset };
188
- placedOrientations: {[_: CrossTileID]: number };
189
- commitTime: number;
190
- prevZoomAdjustment: number;
191
- lastPlacementChangeTime: number;
192
- stale: boolean;
193
- fadeDuration: number;
194
- retainedQueryData: {[_: number]: RetainedQueryData};
195
- collisionGroups: CollisionGroups;
196
- prevPlacement: ?Placement;
197
- zoomAtLastRecencyCheck: number;
198
-
199
- constructor(transform: Transform, fadeDuration: number, crossSourceCollisions: boolean, prevPlacement?: Placement) {
200
- this.transform = transform.clone();
201
- this.collisionIndex = new CollisionIndex(this.transform);
202
- this.placements = {};
203
- this.opacities = {};
204
- this.variableOffsets = {};
205
- this.stale = false;
206
- this.commitTime = 0;
207
- this.fadeDuration = fadeDuration;
208
- this.retainedQueryData = {};
209
- this.collisionGroups = new CollisionGroups(crossSourceCollisions);
210
-
211
- this.prevPlacement = prevPlacement;
212
- if (prevPlacement) {
213
- prevPlacement.prevPlacement = undefined; // Only hold on to one placement back
214
- }
215
-
216
- this.placedOrientations = {};
217
- }
218
-
219
- getBucketParts(results: Array<BucketPart>, styleLayer: StyleLayer, tile: Tile, sortAcrossTiles: boolean) {
220
- const symbolBucket = ((tile.getBucket(styleLayer): any): SymbolBucket);
221
- const bucketFeatureIndex = tile.latestFeatureIndex;
222
- if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0])
223
- return;
224
-
225
- const collisionBoxArray = tile.collisionBoxArray;
226
-
227
- const layout = symbolBucket.layers[0].layout;
228
-
229
- const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ);
230
- const textPixelRatio = tile.tileSize / EXTENT;
231
-
232
- const posMatrix = this.transform.calculatePosMatrix(tile.tileID.toUnwrapped());
233
-
234
- const textLabelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix,
235
- layout.get('text-pitch-alignment') === 'map',
236
- layout.get('text-rotation-alignment') === 'map',
237
- this.transform,
238
- pixelsToTileUnits(tile, 1, this.transform.zoom));
239
-
240
- // As long as this placement lives, we have to hold onto this bucket's
241
- // matching FeatureIndex/data for querying purposes
242
- this.retainedQueryData[symbolBucket.bucketInstanceId] = new RetainedQueryData(
243
- symbolBucket.bucketInstanceId,
244
- bucketFeatureIndex,
245
- symbolBucket.sourceLayerIndex,
246
- symbolBucket.index,
247
- tile.tileID
248
- );
249
-
250
- const parameters = {
251
- bucket: symbolBucket,
252
- layout,
253
- posMatrix,
254
- textLabelPlaneMatrix,
255
- scale,
256
- textPixelRatio,
257
- holdingForFade: tile.holdingForFade(),
258
- collisionBoxArray,
259
- partiallyEvaluatedTextSize: symbolSize.evaluateSizeForZoom(symbolBucket.textSizeData, this.transform.zoom),
260
- collisionGroup: this.collisionGroups.get(symbolBucket.sourceID)
261
- };
262
-
263
- if (sortAcrossTiles) {
264
- for (const range of symbolBucket.sortKeyRanges) {
265
- const {sortKey, symbolInstanceStart, symbolInstanceEnd} = range;
266
- results.push({sortKey, symbolInstanceStart, symbolInstanceEnd, parameters});
267
- }
268
- } else {
269
- results.push({
270
- symbolInstanceStart: 0,
271
- symbolInstanceEnd: symbolBucket.symbolInstances.length,
272
- parameters
273
- });
274
- }
275
- }
276
-
277
- attemptAnchorPlacement(anchor: TextAnchor, textBox: SingleCollisionBox, width: number, height: number,
278
- textBoxScale: number, rotateWithMap: boolean,
279
- pitchWithMap: boolean, textPixelRatio: number, posMatrix: mat4, collisionGroup: CollisionGroup,
280
- textAllowOverlap: boolean, symbolInstance: SymbolInstance, bucket: SymbolBucket, orientation: number, iconBox: ?SingleCollisionBox): ?{ shift: Point, placedGlyphBoxes: { box: Array<number>, offscreen: boolean } } {
281
-
282
- const textOffset = [symbolInstance.textOffset0, symbolInstance.textOffset1];
283
- const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale);
284
-
285
- const placedGlyphBoxes = this.collisionIndex.placeCollisionBox(
286
- shiftVariableCollisionBox(
287
- textBox, shift.x, shift.y,
288
- rotateWithMap, pitchWithMap, this.transform.angle),
289
- textAllowOverlap, textPixelRatio, posMatrix, collisionGroup.predicate);
290
-
291
- if (iconBox) {
292
- const placedIconBoxes = this.collisionIndex.placeCollisionBox(
293
- shiftVariableCollisionBox(
294
- iconBox, shift.x, shift.y,
295
- rotateWithMap, pitchWithMap, this.transform.angle),
296
- textAllowOverlap, textPixelRatio, posMatrix, collisionGroup.predicate);
297
- if (placedIconBoxes.box.length === 0) return;
298
- }
299
-
300
- if (placedGlyphBoxes.box.length > 0) {
301
- let prevAnchor;
302
- // If this label was placed in the previous placement, record the anchor position
303
- // to allow us to animate the transition
304
- if (this.prevPlacement &&
305
- this.prevPlacement.variableOffsets[symbolInstance.crossTileID] &&
306
- this.prevPlacement.placements[symbolInstance.crossTileID] &&
307
- this.prevPlacement.placements[symbolInstance.crossTileID].text) {
308
- prevAnchor = this.prevPlacement.variableOffsets[symbolInstance.crossTileID].anchor;
309
- }
310
- assert(symbolInstance.crossTileID !== 0);
311
- this.variableOffsets[symbolInstance.crossTileID] = {
312
- textOffset,
313
- width,
314
- height,
315
- anchor,
316
- textBoxScale,
317
- prevAnchor
318
- };
319
- this.markUsedJustification(bucket, anchor, symbolInstance, orientation);
320
-
321
- if (bucket.allowVerticalPlacement) {
322
- this.markUsedOrientation(bucket, orientation, symbolInstance);
323
- this.placedOrientations[symbolInstance.crossTileID] = orientation;
324
- }
325
-
326
- return {shift, placedGlyphBoxes};
327
- }
328
- }
329
-
330
- placeLayerBucketPart(bucketPart: Object, seenCrossTileIDs: { [string | number]: boolean }, showCollisionBoxes: boolean) {
331
-
332
- const {
333
- bucket,
334
- layout,
335
- posMatrix,
336
- textLabelPlaneMatrix,
337
- scale,
338
- textPixelRatio,
339
- holdingForFade,
340
- collisionBoxArray,
341
- partiallyEvaluatedTextSize,
342
- collisionGroup
343
- } = bucketPart.parameters;
344
-
345
- const textOptional = layout.get('text-optional');
346
- const iconOptional = layout.get('icon-optional');
347
- const textAllowOverlap = layout.get('text-allow-overlap');
348
- const iconAllowOverlap = layout.get('icon-allow-overlap');
349
- const rotateWithMap = layout.get('text-rotation-alignment') === 'map';
350
- const pitchWithMap = layout.get('text-pitch-alignment') === 'map';
351
- const hasIconTextFit = layout.get('icon-text-fit') !== 'none';
352
- const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y';
353
-
354
- // This logic is similar to the "defaultOpacityState" logic below in updateBucketOpacities
355
- // If we know a symbol is always supposed to show, force it to be marked visible even if
356
- // it wasn't placed into the collision index (because some or all of it was outside the range
357
- // of the collision grid).
358
- // There is a subtle edge case here we're accepting:
359
- // Symbol A has text-allow-overlap: true, icon-allow-overlap: true, icon-optional: false
360
- // A's icon is outside the grid, so doesn't get placed
361
- // A's text would be inside grid, but doesn't get placed because of icon-optional: false
362
- // We still show A because of the allow-overlap settings.
363
- // Symbol B has allow-overlap: false, and gets placed where A's text would be
364
- // On panning in, there is a short period when Symbol B and Symbol A will overlap
365
- // This is the reverse of our normal policy of "fade in on pan", but should look like any other
366
- // collision and hopefully not be too noticeable.
367
- // See https://github.com/mapbox/mapbox-gl-js/issues/7172
368
- const alwaysShowText = textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || iconOptional);
369
- const alwaysShowIcon = iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || textOptional);
370
-
371
- if (!bucket.collisionArrays && collisionBoxArray) {
372
- bucket.deserializeCollisionBoxes(collisionBoxArray);
373
- }
374
-
375
- const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => {
376
- if (seenCrossTileIDs[symbolInstance.crossTileID]) return;
377
- if (holdingForFade) {
378
- // Mark all symbols from this tile as "not placed", but don't add to seenCrossTileIDs, because we don't
379
- // know yet if we have a duplicate in a parent tile that _should_ be placed.
380
- this.placements[symbolInstance.crossTileID] = new JointPlacement(false, false, false);
381
- return;
382
- }
383
-
384
- let placeText = false;
385
- let placeIcon = false;
386
- let offscreen = true;
387
- let shift = null;
388
-
389
- let placed = {box: null, offscreen: null};
390
- let placedVerticalText = {box: null, offscreen: null};
391
-
392
- let placedGlyphBoxes = null;
393
- let placedGlyphCircles = null;
394
- let placedIconBoxes = null;
395
- let textFeatureIndex = 0;
396
- let verticalTextFeatureIndex = 0;
397
- let iconFeatureIndex = 0;
398
-
399
- if (collisionArrays.textFeatureIndex) {
400
- textFeatureIndex = collisionArrays.textFeatureIndex;
401
- }
402
- if (collisionArrays.verticalTextFeatureIndex) {
403
- verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex;
404
- }
405
-
406
- const textBox = collisionArrays.textBox;
407
- if (textBox) {
408
-
409
- const updatePreviousOrientationIfNotPlaced = (isPlaced) => {
410
- let previousOrientation = WritingMode.horizontal;
411
- if (bucket.allowVerticalPlacement && !isPlaced && this.prevPlacement) {
412
- const prevPlacedOrientation = this.prevPlacement.placedOrientations[symbolInstance.crossTileID];
413
- if (prevPlacedOrientation) {
414
- this.placedOrientations[symbolInstance.crossTileID] = prevPlacedOrientation;
415
- previousOrientation = prevPlacedOrientation;
416
- this.markUsedOrientation(bucket, previousOrientation, symbolInstance);
417
- }
418
- }
419
- return previousOrientation;
420
- };
421
-
422
- const placeTextForPlacementModes = (placeHorizontalFn, placeVerticalFn) => {
423
- if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && collisionArrays.verticalTextBox) {
424
- for (const placementMode of bucket.writingModes) {
425
- if (placementMode === WritingMode.vertical) {
426
- placed = placeVerticalFn();
427
- placedVerticalText = placed;
428
- } else {
429
- placed = placeHorizontalFn();
430
- }
431
- if (placed && placed.box && placed.box.length) break;
432
- }
433
- } else {
434
- placed = placeHorizontalFn();
435
- }
436
- };
437
-
438
- if (!layout.get('text-variable-anchor')) {
439
- const placeBox = (collisionTextBox, orientation) => {
440
- const placedFeature = this.collisionIndex.placeCollisionBox(collisionTextBox, textAllowOverlap,
441
- textPixelRatio, posMatrix, collisionGroup.predicate);
442
- if (placedFeature && placedFeature.box && placedFeature.box.length) {
443
- this.markUsedOrientation(bucket, orientation, symbolInstance);
444
- this.placedOrientations[symbolInstance.crossTileID] = orientation;
445
- }
446
- return placedFeature;
447
- };
448
-
449
- const placeHorizontal = () => {
450
- return placeBox(textBox, WritingMode.horizontal);
451
- };
452
-
453
- const placeVertical = () => {
454
- const verticalTextBox = collisionArrays.verticalTextBox;
455
- if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {
456
- return placeBox(verticalTextBox, WritingMode.vertical);
457
- }
458
- return {box: null, offscreen: null};
459
- };
460
-
461
- placeTextForPlacementModes(placeHorizontal, placeVertical);
462
- updatePreviousOrientationIfNotPlaced(placed && placed.box && placed.box.length);
463
-
464
- } else {
465
- let anchors = layout.get('text-variable-anchor');
466
-
467
- // If this symbol was in the last placement, shift the previously used
468
- // anchor to the front of the anchor list, only if the previous anchor
469
- // is still in the anchor list
470
- if (this.prevPlacement && this.prevPlacement.variableOffsets[symbolInstance.crossTileID]) {
471
- const prevOffsets = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];
472
- if (anchors.indexOf(prevOffsets.anchor) > 0) {
473
- anchors = anchors.filter(anchor => anchor !== prevOffsets.anchor);
474
- anchors.unshift(prevOffsets.anchor);
475
- }
476
- }
477
-
478
- const placeBoxForVariableAnchors = (collisionTextBox, collisionIconBox, orientation) => {
479
- const width = collisionTextBox.x2 - collisionTextBox.x1;
480
- const height = collisionTextBox.y2 - collisionTextBox.y1;
481
- const textBoxScale = symbolInstance.textBoxScale;
482
-
483
- const variableIconBox = hasIconTextFit && !iconAllowOverlap ? collisionIconBox : null;
484
-
485
- let placedBox: ?{ box: Array<number>, offscreen: boolean } = {box: [], offscreen: false};
486
- const placementAttempts = textAllowOverlap ? anchors.length * 2 : anchors.length;
487
- for (let i = 0; i < placementAttempts; ++i) {
488
- const anchor = anchors[i % anchors.length];
489
- const allowOverlap = (i >= anchors.length);
490
- const result = this.attemptAnchorPlacement(
491
- anchor, collisionTextBox, width, height,
492
- textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix,
493
- collisionGroup, allowOverlap, symbolInstance, bucket, orientation, variableIconBox);
494
-
495
- if (result) {
496
- placedBox = result.placedGlyphBoxes;
497
- if (placedBox && placedBox.box && placedBox.box.length) {
498
- placeText = true;
499
- shift = result.shift;
500
- break;
501
- }
502
- }
503
- }
504
-
505
- return placedBox;
506
- };
507
-
508
- const placeHorizontal = () => {
509
- return placeBoxForVariableAnchors(textBox, collisionArrays.iconBox, WritingMode.horizontal);
510
- };
511
-
512
- const placeVertical = () => {
513
- const verticalTextBox = collisionArrays.verticalTextBox;
514
- const wasPlaced = placed && placed.box && placed.box.length;
515
- if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) {
516
- return placeBoxForVariableAnchors(verticalTextBox, collisionArrays.verticalIconBox, WritingMode.vertical);
517
- }
518
- return {box: null, offscreen: null};
519
- };
520
-
521
- placeTextForPlacementModes(placeHorizontal, placeVertical);
522
-
523
- if (placed) {
524
- placeText = placed.box;
525
- offscreen = placed.offscreen;
526
- }
527
-
528
- const prevOrientation = updatePreviousOrientationIfNotPlaced(placed && placed.box);
529
-
530
- // If we didn't get placed, we still need to copy our position from the last placement for
531
- // fade animations
532
- if (!placeText && this.prevPlacement) {
533
- const prevOffset = this.prevPlacement.variableOffsets[symbolInstance.crossTileID];
534
- if (prevOffset) {
535
- this.variableOffsets[symbolInstance.crossTileID] = prevOffset;
536
- this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, prevOrientation);
537
- }
538
- }
539
-
540
- }
541
- }
542
-
543
- placedGlyphBoxes = placed;
544
- placeText = placedGlyphBoxes && placedGlyphBoxes.box && placedGlyphBoxes.box.length > 0;
545
-
546
- offscreen = placedGlyphBoxes && placedGlyphBoxes.offscreen;
547
- const textCircles = collisionArrays.textCircles;
548
- if (textCircles) {
549
- const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.centerJustifiedTextSymbolIndex);
550
- const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol);
551
- placedGlyphCircles = this.collisionIndex.placeCollisionCircles(textCircles,
552
- textAllowOverlap,
553
- scale,
554
- textPixelRatio,
555
- placedSymbol,
556
- bucket.lineVertexArray,
557
- bucket.glyphOffsetArray,
558
- fontSize,
559
- posMatrix,
560
- textLabelPlaneMatrix,
561
- showCollisionBoxes,
562
- pitchWithMap,
563
- collisionGroup.predicate);
564
- // If text-allow-overlap is set, force "placedCircles" to true
565
- // In theory there should always be at least one circle placed
566
- // in this case, but for now quirks in text-anchor
567
- // and text-offset may prevent that from being true.
568
- placeText = textAllowOverlap || placedGlyphCircles.circles.length > 0;
569
- offscreen = offscreen && placedGlyphCircles.offscreen;
570
- }
571
-
572
- if (collisionArrays.iconFeatureIndex) {
573
- iconFeatureIndex = collisionArrays.iconFeatureIndex;
574
- }
575
-
576
- if (collisionArrays.iconBox) {
577
-
578
- const placeIconFeature = iconBox => {
579
- const shiftedIconBox = hasIconTextFit && shift ?
580
- shiftVariableCollisionBox(
581
- iconBox, shift.x, shift.y,
582
- rotateWithMap, pitchWithMap, this.transform.angle) :
583
- iconBox;
584
- return this.collisionIndex.placeCollisionBox(shiftedIconBox,
585
- iconAllowOverlap, textPixelRatio, posMatrix, collisionGroup.predicate);
586
- };
587
-
588
- if (placedVerticalText && placedVerticalText.box && placedVerticalText.box.length && collisionArrays.verticalIconBox) {
589
- placedIconBoxes = placeIconFeature(collisionArrays.verticalIconBox);
590
- placeIcon = placedIconBoxes.box.length > 0;
591
- } else {
592
- placedIconBoxes = placeIconFeature(collisionArrays.iconBox);
593
- placeIcon = placedIconBoxes.box.length > 0;
594
- }
595
- offscreen = offscreen && placedIconBoxes.offscreen;
596
- }
597
-
598
- const iconWithoutText = textOptional ||
599
- (symbolInstance.numHorizontalGlyphVertices === 0 && symbolInstance.numVerticalGlyphVertices === 0);
600
- const textWithoutIcon = iconOptional || symbolInstance.numIconVertices === 0;
601
-
602
- // Combine the scales for icons and text.
603
- if (!iconWithoutText && !textWithoutIcon) {
604
- placeIcon = placeText = placeIcon && placeText;
605
- } else if (!textWithoutIcon) {
606
- placeText = placeIcon && placeText;
607
- } else if (!iconWithoutText) {
608
- placeIcon = placeIcon && placeText;
609
- }
610
-
611
- if (placeText && placedGlyphBoxes && placedGlyphBoxes.box) {
612
- if (placedVerticalText && placedVerticalText.box && verticalTextFeatureIndex) {
613
- this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, layout.get('text-ignore-placement'),
614
- bucket.bucketInstanceId, verticalTextFeatureIndex, collisionGroup.ID);
615
- } else {
616
- this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, layout.get('text-ignore-placement'),
617
- bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID);
618
- }
619
-
620
- }
621
- if (placeIcon && placedIconBoxes) {
622
- this.collisionIndex.insertCollisionBox(placedIconBoxes.box, layout.get('icon-ignore-placement'),
623
- bucket.bucketInstanceId, iconFeatureIndex, collisionGroup.ID);
624
- }
625
- if (placeText && placedGlyphCircles) {
626
- this.collisionIndex.insertCollisionCircles(placedGlyphCircles.circles, layout.get('text-ignore-placement'),
627
- bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID);
628
- }
629
-
630
- assert(symbolInstance.crossTileID !== 0);
631
- assert(bucket.bucketInstanceId !== 0);
632
-
633
- this.placements[symbolInstance.crossTileID] = new JointPlacement(placeText || alwaysShowText, placeIcon || alwaysShowIcon, offscreen || bucket.justReloaded);
634
- seenCrossTileIDs[symbolInstance.crossTileID] = true;
635
- };
636
-
637
- if (zOrderByViewportY) {
638
- assert(bucketPart.symbolInstanceStart === 0);
639
- const symbolIndexes = bucket.getSortedSymbolIndexes(this.transform.angle);
640
- for (let i = symbolIndexes.length - 1; i >= 0; --i) {
641
- const symbolIndex = symbolIndexes[i];
642
- placeSymbol(bucket.symbolInstances.get(symbolIndex), bucket.collisionArrays[symbolIndex]);
643
- }
644
- } else {
645
- for (let i = bucketPart.symbolInstanceStart; i < bucketPart.symbolInstanceEnd; i++) {
646
- placeSymbol(bucket.symbolInstances.get(i), bucket.collisionArrays[i]);
647
- }
648
- }
649
-
650
- bucket.justReloaded = false;
651
- }
652
-
653
- markUsedJustification(bucket: SymbolBucket, placedAnchor: TextAnchor, symbolInstance: SymbolInstance, orientation: number) {
654
- const justifications = {
655
- "left": symbolInstance.leftJustifiedTextSymbolIndex,
656
- "center": symbolInstance.centerJustifiedTextSymbolIndex,
657
- "right": symbolInstance.rightJustifiedTextSymbolIndex
658
- };
659
-
660
- let autoIndex;
661
- if (orientation === WritingMode.vertical) {
662
- autoIndex = symbolInstance.verticalPlacedTextSymbolIndex;
663
- } else {
664
- autoIndex = justifications[getAnchorJustification(placedAnchor)];
665
- }
666
-
667
- const indexes = [
668
- symbolInstance.leftJustifiedTextSymbolIndex,
669
- symbolInstance.centerJustifiedTextSymbolIndex,
670
- symbolInstance.rightJustifiedTextSymbolIndex,
671
- symbolInstance.verticalPlacedTextSymbolIndex
672
- ];
673
-
674
- for (const index of indexes) {
675
- if (index >= 0) {
676
- if (autoIndex >= 0 && index !== autoIndex) {
677
- // There are multiple justifications and this one isn't it: shift offscreen
678
- bucket.text.placedSymbolArray.get(index).crossTileID = 0;
679
- } else {
680
- // Either this is the chosen justification or the justification is hardwired: use this one
681
- bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID;
682
- }
683
- }
684
- }
685
- }
686
-
687
- markUsedOrientation(bucket: SymbolBucket, orientation: number, symbolInstance: SymbolInstance) {
688
- const horizontal = (orientation === WritingMode.horizontal || orientation === WritingMode.horizontalOnly) ? orientation : 0;
689
- const vertical = orientation === WritingMode.vertical ? orientation : 0;
690
-
691
- const horizontalIndexes = [
692
- symbolInstance.leftJustifiedTextSymbolIndex,
693
- symbolInstance.centerJustifiedTextSymbolIndex,
694
- symbolInstance.rightJustifiedTextSymbolIndex
695
- ];
696
-
697
- for (const index of horizontalIndexes) {
698
- bucket.text.placedSymbolArray.get(index).placedOrientation = horizontal;
699
- }
700
-
701
- if (symbolInstance.verticalPlacedTextSymbolIndex) {
702
- bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).placedOrientation = vertical;
703
- }
704
- }
705
-
706
- commit(now: number): void {
707
- this.commitTime = now;
708
- this.zoomAtLastRecencyCheck = this.transform.zoom;
709
-
710
- const prevPlacement = this.prevPlacement;
711
- let placementChanged = false;
712
-
713
- this.prevZoomAdjustment = prevPlacement ? prevPlacement.zoomAdjustment(this.transform.zoom) : 0;
714
- const increment = prevPlacement ? prevPlacement.symbolFadeChange(now) : 1;
715
-
716
- const prevOpacities = prevPlacement ? prevPlacement.opacities : {};
717
- const prevOffsets = prevPlacement ? prevPlacement.variableOffsets : {};
718
- const prevOrientations = prevPlacement ? prevPlacement.placedOrientations : {};
719
-
720
- // add the opacities from the current placement, and copy their current values from the previous placement
721
- for (const crossTileID in this.placements) {
722
- const jointPlacement = this.placements[crossTileID];
723
- const prevOpacity = prevOpacities[crossTileID];
724
- if (prevOpacity) {
725
- this.opacities[crossTileID] = new JointOpacityState(prevOpacity, increment, jointPlacement.text, jointPlacement.icon);
726
- placementChanged = placementChanged ||
727
- jointPlacement.text !== prevOpacity.text.placed ||
728
- jointPlacement.icon !== prevOpacity.icon.placed;
729
- } else {
730
- this.opacities[crossTileID] = new JointOpacityState(null, increment, jointPlacement.text, jointPlacement.icon, jointPlacement.skipFade);
731
- placementChanged = placementChanged || jointPlacement.text || jointPlacement.icon;
732
- }
733
- }
734
-
735
- // copy and update values from the previous placement that aren't in the current placement but haven't finished fading
736
- for (const crossTileID in prevOpacities) {
737
- const prevOpacity = prevOpacities[crossTileID];
738
- if (!this.opacities[crossTileID]) {
739
- const jointOpacity = new JointOpacityState(prevOpacity, increment, false, false);
740
- if (!jointOpacity.isHidden()) {
741
- this.opacities[crossTileID] = jointOpacity;
742
- placementChanged = placementChanged || prevOpacity.text.placed || prevOpacity.icon.placed;
743
- }
744
- }
745
- }
746
- for (const crossTileID in prevOffsets) {
747
- if (!this.variableOffsets[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {
748
- this.variableOffsets[crossTileID] = prevOffsets[crossTileID];
749
- }
750
- }
751
-
752
- for (const crossTileID in prevOrientations) {
753
- if (!this.placedOrientations[crossTileID] && this.opacities[crossTileID] && !this.opacities[crossTileID].isHidden()) {
754
- this.placedOrientations[crossTileID] = prevOrientations[crossTileID];
755
- }
756
- }
757
-
758
- // this.lastPlacementChangeTime is the time of the last commit() that
759
- // resulted in a placement change -- in other words, the start time of
760
- // the last symbol fade animation
761
- assert(!prevPlacement || prevPlacement.lastPlacementChangeTime !== undefined);
762
- if (placementChanged) {
763
- this.lastPlacementChangeTime = now;
764
- } else if (typeof this.lastPlacementChangeTime !== 'number') {
765
- this.lastPlacementChangeTime = prevPlacement ? prevPlacement.lastPlacementChangeTime : now;
766
- }
767
- }
768
-
769
- updateLayerOpacities(styleLayer: StyleLayer, tiles: Array<Tile>) {
770
- const seenCrossTileIDs = {};
771
- for (const tile of tiles) {
772
- const symbolBucket = ((tile.getBucket(styleLayer): any): SymbolBucket);
773
- if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {
774
- this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);
775
- }
776
- }
777
- }
778
-
779
- updateBucketOpacities(bucket: SymbolBucket, seenCrossTileIDs: { [string | number]: boolean }, collisionBoxArray: ?CollisionBoxArray) {
780
- if (bucket.hasTextData()) bucket.text.opacityVertexArray.clear();
781
- if (bucket.hasIconData()) bucket.icon.opacityVertexArray.clear();
782
- if (bucket.hasIconCollisionBoxData()) bucket.iconCollisionBox.collisionVertexArray.clear();
783
- if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox.collisionVertexArray.clear();
784
- if (bucket.hasIconCollisionCircleData()) bucket.iconCollisionCircle.collisionVertexArray.clear();
785
- if (bucket.hasTextCollisionCircleData()) bucket.textCollisionCircle.collisionVertexArray.clear();
786
-
787
- const layout = bucket.layers[0].layout;
788
- const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true);
789
- const textAllowOverlap = layout.get('text-allow-overlap');
790
- const iconAllowOverlap = layout.get('icon-allow-overlap');
791
- const variablePlacement = layout.get('text-variable-anchor');
792
- const rotateWithMap = layout.get('text-rotation-alignment') === 'map';
793
- const pitchWithMap = layout.get('text-pitch-alignment') === 'map';
794
- const hasIconTextFit = layout.get('icon-text-fit') !== 'none';
795
- // If allow-overlap is true, we can show symbols before placement runs on them
796
- // But we have to wait for placement if we potentially depend on a paired icon/text
797
- // with allow-overlap: false.
798
- // See https://github.com/mapbox/mapbox-gl-js/issues/7032
799
- const defaultOpacityState = new JointOpacityState(null, 0,
800
- textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || layout.get('icon-optional')),
801
- iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || layout.get('text-optional')),
802
- true);
803
-
804
- if (!bucket.collisionArrays && collisionBoxArray && ((bucket.hasIconCollisionBoxData() || bucket.hasIconCollisionCircleData() ||
805
- bucket.hasTextCollisionBoxData() || bucket.hasTextCollisionCircleData()))) {
806
- bucket.deserializeCollisionBoxes(collisionBoxArray);
807
- }
808
-
809
- const addOpacities = (iconOrText, numVertices: number, opacity: number) => {
810
- for (let i = 0; i < numVertices / 4; i++) {
811
- iconOrText.opacityVertexArray.emplaceBack(opacity);
812
- }
813
- };
814
-
815
- for (let s = 0; s < bucket.symbolInstances.length; s++) {
816
- const symbolInstance = bucket.symbolInstances.get(s);
817
- const {
818
- numHorizontalGlyphVertices,
819
- numVerticalGlyphVertices,
820
- crossTileID
821
- } = symbolInstance;
822
-
823
- const isDuplicate = seenCrossTileIDs[crossTileID];
824
-
825
- let opacityState = this.opacities[crossTileID];
826
- if (isDuplicate) {
827
- opacityState = duplicateOpacityState;
828
- } else if (!opacityState) {
829
- opacityState = defaultOpacityState;
830
- // store the state so that future placements use it as a starting point
831
- this.opacities[crossTileID] = opacityState;
832
- }
833
-
834
- seenCrossTileIDs[crossTileID] = true;
835
-
836
- const hasText = numHorizontalGlyphVertices > 0 || numVerticalGlyphVertices > 0;
837
- const hasIcon = symbolInstance.numIconVertices > 0;
838
-
839
- const placedOrientation = this.placedOrientations[symbolInstance.crossTileID];
840
- const horizontalHidden = placedOrientation === WritingMode.vertical;
841
- const verticalHidden = placedOrientation === WritingMode.horizontal || placedOrientation === WritingMode.horizontalOnly;
842
-
843
- if (hasText) {
844
- const packedOpacity = packOpacity(opacityState.text);
845
- // Vertical text fades in/out on collision the same way as corresponding
846
- // horizontal text. Switch between vertical/horizontal should be instantaneous
847
- const horizontalOpacity = horizontalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;
848
- addOpacities(bucket.text, numHorizontalGlyphVertices, horizontalOpacity);
849
- const verticalOpacity = verticalHidden ? PACKED_HIDDEN_OPACITY : packedOpacity;
850
- addOpacities(bucket.text, numVerticalGlyphVertices, verticalOpacity);
851
-
852
- // If this label is completely faded, mark it so that we don't have to calculate
853
- // its position at render time. If this layer has variable placement, shift the various
854
- // symbol instances appropriately so that symbols from buckets that have yet to be placed
855
- // offset appropriately.
856
- const symbolHidden = opacityState.text.isHidden();
857
- [
858
- symbolInstance.rightJustifiedTextSymbolIndex,
859
- symbolInstance.centerJustifiedTextSymbolIndex,
860
- symbolInstance.leftJustifiedTextSymbolIndex
861
- ].forEach(index => {
862
- if (index >= 0) {
863
- bucket.text.placedSymbolArray.get(index).hidden = symbolHidden || horizontalHidden ? 1 : 0;
864
- }
865
- });
866
-
867
- if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {
868
- bucket.text.placedSymbolArray.get(symbolInstance.verticalPlacedTextSymbolIndex).hidden = symbolHidden || verticalHidden ? 1 : 0;
869
- }
870
-
871
- const prevOffset = this.variableOffsets[symbolInstance.crossTileID];
872
- if (prevOffset) {
873
- this.markUsedJustification(bucket, prevOffset.anchor, symbolInstance, placedOrientation);
874
- }
875
-
876
- const prevOrientation = this.placedOrientations[symbolInstance.crossTileID];
877
- if (prevOrientation) {
878
- this.markUsedJustification(bucket, 'left', symbolInstance, prevOrientation);
879
- this.markUsedOrientation(bucket, prevOrientation, symbolInstance);
880
- }
881
- }
882
-
883
- if (hasIcon) {
884
- const packedOpacity = packOpacity(opacityState.icon);
885
-
886
- const useHorizontal = !(hasIconTextFit && symbolInstance.verticalPlacedIconSymbolIndex && horizontalHidden);
887
-
888
- if (symbolInstance.placedIconSymbolIndex >= 0) {
889
- const horizontalOpacity = useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;
890
- addOpacities(bucket.icon, symbolInstance.numIconVertices, horizontalOpacity);
891
- bucket.icon.placedSymbolArray.get(symbolInstance.placedIconSymbolIndex).hidden =
892
- (opacityState.icon.isHidden(): any);
893
- }
894
-
895
- if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {
896
- const verticalOpacity = !useHorizontal ? packedOpacity : PACKED_HIDDEN_OPACITY;
897
- addOpacities(bucket.icon, symbolInstance.numVerticalIconVertices, verticalOpacity);
898
- bucket.icon.placedSymbolArray.get(symbolInstance.verticalPlacedIconSymbolIndex).hidden =
899
- (opacityState.icon.isHidden(): any);
900
- }
901
- }
902
-
903
- if (bucket.hasIconCollisionBoxData() || bucket.hasIconCollisionCircleData() ||
904
- bucket.hasTextCollisionBoxData() || bucket.hasTextCollisionCircleData()) {
905
- const collisionArrays = bucket.collisionArrays[s];
906
- if (collisionArrays) {
907
- let shift = new Point(0, 0);
908
- if (collisionArrays.textBox || collisionArrays.verticalTextBox) {
909
- let used = true;
910
- if (variablePlacement) {
911
- const variableOffset = this.variableOffsets[crossTileID];
912
- if (variableOffset) {
913
- // This will show either the currently placed position or the last
914
- // successfully placed position (so you can visualize what collision
915
- // just made the symbol disappear, and the most likely place for the
916
- // symbol to come back)
917
- shift = calculateVariableLayoutShift(variableOffset.anchor,
918
- variableOffset.width,
919
- variableOffset.height,
920
- variableOffset.textOffset,
921
- variableOffset.textBoxScale);
922
- if (rotateWithMap) {
923
- shift._rotate(pitchWithMap ? this.transform.angle : -this.transform.angle);
924
- }
925
- } else {
926
- // No offset -> this symbol hasn't been placed since coming on-screen
927
- // No single box is particularly meaningful and all of them would be too noisy
928
- // Use the center box just to show something's there, but mark it "not used"
929
- used = false;
930
- }
931
- }
932
-
933
- if (collisionArrays.textBox) {
934
- updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || horizontalHidden, shift.x, shift.y);
935
- }
936
- if (collisionArrays.verticalTextBox) {
937
- updateCollisionVertices(bucket.textCollisionBox.collisionVertexArray, opacityState.text.placed, !used || verticalHidden, shift.x, shift.y);
938
- }
939
- }
940
-
941
- const verticalIconUsed = Boolean(!verticalHidden && collisionArrays.verticalIconBox);
942
-
943
- if (collisionArrays.iconBox) {
944
- updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, verticalIconUsed,
945
- hasIconTextFit ? shift.x : 0,
946
- hasIconTextFit ? shift.y : 0);
947
- }
948
-
949
- if (collisionArrays.verticalIconBox) {
950
- updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, !verticalIconUsed,
951
- hasIconTextFit ? shift.x : 0,
952
- hasIconTextFit ? shift.y : 0);
953
- }
954
-
955
- const textCircles = collisionArrays.textCircles;
956
- if (textCircles && bucket.hasTextCollisionCircleData()) {
957
- for (let k = 0; k < textCircles.length; k += 5) {
958
- const notUsed = isDuplicate || textCircles[k + 4] === 0;
959
- updateCollisionVertices(bucket.textCollisionCircle.collisionVertexArray, opacityState.text.placed, notUsed);
960
- }
961
- }
962
- }
963
- }
964
- }
965
-
966
- bucket.sortFeatures(this.transform.angle);
967
- if (this.retainedQueryData[bucket.bucketInstanceId]) {
968
- this.retainedQueryData[bucket.bucketInstanceId].featureSortOrder = bucket.featureSortOrder;
969
- }
970
-
971
- if (bucket.hasTextData() && bucket.text.opacityVertexBuffer) {
972
- bucket.text.opacityVertexBuffer.updateData(bucket.text.opacityVertexArray);
973
- }
974
- if (bucket.hasIconData() && bucket.icon.opacityVertexBuffer) {
975
- bucket.icon.opacityVertexBuffer.updateData(bucket.icon.opacityVertexArray);
976
- }
977
- if (bucket.hasIconCollisionBoxData() && bucket.iconCollisionBox.collisionVertexBuffer) {
978
- bucket.iconCollisionBox.collisionVertexBuffer.updateData(bucket.iconCollisionBox.collisionVertexArray);
979
- }
980
- if (bucket.hasTextCollisionBoxData() && bucket.textCollisionBox.collisionVertexBuffer) {
981
- bucket.textCollisionBox.collisionVertexBuffer.updateData(bucket.textCollisionBox.collisionVertexArray);
982
- }
983
- if (bucket.hasIconCollisionCircleData() && bucket.iconCollisionCircle.collisionVertexBuffer) {
984
- bucket.iconCollisionCircle.collisionVertexBuffer.updateData(bucket.iconCollisionCircle.collisionVertexArray);
985
- }
986
- if (bucket.hasTextCollisionCircleData() && bucket.textCollisionCircle.collisionVertexBuffer) {
987
- bucket.textCollisionCircle.collisionVertexBuffer.updateData(bucket.textCollisionCircle.collisionVertexArray);
988
- }
989
-
990
- assert(bucket.text.opacityVertexArray.length === bucket.text.layoutVertexArray.length / 4);
991
- assert(bucket.icon.opacityVertexArray.length === bucket.icon.layoutVertexArray.length / 4);
992
- }
993
-
994
- symbolFadeChange(now: number) {
995
- return this.fadeDuration === 0 ?
996
- 1 :
997
- ((now - this.commitTime) / this.fadeDuration + this.prevZoomAdjustment);
998
- }
999
-
1000
- zoomAdjustment(zoom: number) {
1001
- // When zooming out quickly, labels can overlap each other. This
1002
- // adjustment is used to reduce the interval between placement calculations
1003
- // and to reduce the fade duration when zooming out quickly. Discovering the
1004
- // collisions more quickly and fading them more quickly reduces the unwanted effect.
1005
- return Math.max(0, (this.transform.zoom - zoom) / 1.5);
1006
- }
1007
-
1008
- hasTransitions(now: number) {
1009
- return this.stale ||
1010
- now - this.lastPlacementChangeTime < this.fadeDuration;
1011
- }
1012
-
1013
- stillRecent(now: number, zoom: number) {
1014
- // The adjustment makes placement more frequent when zooming.
1015
- // This condition applies the adjustment only after the map has
1016
- // stopped zooming. This avoids adding extra jank while zooming.
1017
- const durationAdjustment = this.zoomAtLastRecencyCheck === zoom ?
1018
- (1 - this.zoomAdjustment(zoom)) :
1019
- 1;
1020
- this.zoomAtLastRecencyCheck = zoom;
1021
-
1022
- return this.commitTime + this.fadeDuration * durationAdjustment > now;
1023
- }
1024
-
1025
- setStale() {
1026
- this.stale = true;
1027
- }
1028
- }
1029
-
1030
- function updateCollisionVertices(collisionVertexArray: CollisionVertexArray, placed: boolean, notUsed: boolean | number, shiftX?: number, shiftY?: number) {
1031
- collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);
1032
- collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);
1033
- collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);
1034
- collisionVertexArray.emplaceBack(placed ? 1 : 0, notUsed ? 1 : 0, shiftX || 0, shiftY || 0);
1035
- }
1036
-
1037
- // All four vertices for a glyph will have the same opacity state
1038
- // So we pack the opacity into a uint8, and then repeat it four times
1039
- // to make a single uint32 that we can upload for each glyph in the
1040
- // label.
1041
- const shift25 = Math.pow(2, 25);
1042
- const shift24 = Math.pow(2, 24);
1043
- const shift17 = Math.pow(2, 17);
1044
- const shift16 = Math.pow(2, 16);
1045
- const shift9 = Math.pow(2, 9);
1046
- const shift8 = Math.pow(2, 8);
1047
- const shift1 = Math.pow(2, 1);
1048
- function packOpacity(opacityState: OpacityState): number {
1049
- if (opacityState.opacity === 0 && !opacityState.placed) {
1050
- return 0;
1051
- } else if (opacityState.opacity === 1 && opacityState.placed) {
1052
- return 4294967295;
1053
- }
1054
- const targetBit = opacityState.placed ? 1 : 0;
1055
- const opacityBits = Math.floor(opacityState.opacity * 127);
1056
- return opacityBits * shift25 + targetBit * shift24 +
1057
- opacityBits * shift17 + targetBit * shift16 +
1058
- opacityBits * shift9 + targetBit * shift8 +
1059
- opacityBits * shift1 + targetBit;
1060
- }
1061
-
1062
- const PACKED_HIDDEN_OPACITY = 0;