@mapwhit/tilerenderer 0.47.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 (356) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +25 -0
  3. package/build/min/.dir +0 -0
  4. package/build/min/package.json +3 -0
  5. package/build/min/src/shaders/_prelude.fragment.glsl.txt +13 -0
  6. package/build/min/src/shaders/_prelude.vertex.glsl.txt +14 -0
  7. package/build/min/src/shaders/background.fragment.glsl.txt +5 -0
  8. package/build/min/src/shaders/background.vertex.glsl.txt +1 -0
  9. package/build/min/src/shaders/background_pattern.fragment.glsl.txt +5 -0
  10. package/build/min/src/shaders/background_pattern.vertex.glsl.txt +1 -0
  11. package/build/min/src/shaders/circle.fragment.glsl.txt +20 -0
  12. package/build/min/src/shaders/circle.vertex.glsl.txt +17 -0
  13. package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +1 -0
  14. package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +1 -0
  15. package/build/min/src/shaders/collision_box.fragment.glsl.txt +1 -0
  16. package/build/min/src/shaders/collision_box.vertex.glsl.txt +1 -0
  17. package/build/min/src/shaders/collision_circle.fragment.glsl.txt +1 -0
  18. package/build/min/src/shaders/collision_circle.vertex.glsl.txt +1 -0
  19. package/build/min/src/shaders/debug.fragment.glsl.txt +1 -0
  20. package/build/min/src/shaders/debug.vertex.glsl.txt +1 -0
  21. package/build/min/src/shaders/fill.fragment.glsl.txt +10 -0
  22. package/build/min/src/shaders/fill.vertex.glsl.txt +7 -0
  23. package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +13 -0
  24. package/build/min/src/shaders/fill_extrusion.vertex.glsl.txt +9 -0
  25. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.txt +15 -0
  26. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.txt +11 -0
  27. package/build/min/src/shaders/fill_outline.fragment.glsl.txt +10 -0
  28. package/build/min/src/shaders/fill_outline.vertex.glsl.txt +7 -0
  29. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.txt +13 -0
  30. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.txt +9 -0
  31. package/build/min/src/shaders/fill_pattern.fragment.glsl.txt +13 -0
  32. package/build/min/src/shaders/fill_pattern.vertex.glsl.txt +9 -0
  33. package/build/min/src/shaders/heatmap.fragment.glsl.txt +10 -0
  34. package/build/min/src/shaders/heatmap.vertex.glsl.txt +8 -0
  35. package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +5 -0
  36. package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +1 -0
  37. package/build/min/src/shaders/hillshade.fragment.glsl.txt +7 -0
  38. package/build/min/src/shaders/hillshade.vertex.glsl.txt +1 -0
  39. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.txt +8 -0
  40. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +1 -0
  41. package/build/min/src/shaders/line.fragment.glsl.txt +12 -0
  42. package/build/min/src/shaders/line.vertex.glsl.txt +17 -0
  43. package/build/min/src/shaders/line_gradient.fragment.glsl.txt +10 -0
  44. package/build/min/src/shaders/line_gradient.vertex.glsl.txt +16 -0
  45. package/build/min/src/shaders/line_pattern.fragment.glsl.txt +15 -0
  46. package/build/min/src/shaders/line_pattern.vertex.glsl.txt +20 -0
  47. package/build/min/src/shaders/line_sdf.fragment.glsl.txt +17 -0
  48. package/build/min/src/shaders/line_sdf.vertex.glsl.txt +20 -0
  49. package/build/min/src/shaders/raster.fragment.glsl.txt +5 -0
  50. package/build/min/src/shaders/raster.vertex.glsl.txt +1 -0
  51. package/build/min/src/shaders/symbol_icon.fragment.glsl.txt +9 -0
  52. package/build/min/src/shaders/symbol_icon.vertex.glsl.txt +5 -0
  53. package/build/min/src/shaders/symbol_sdf.fragment.glsl.txt +19 -0
  54. package/build/min/src/shaders/symbol_sdf.vertex.glsl.txt +13 -0
  55. package/package.json +44 -0
  56. package/src/css/mapbox-gl.css +506 -0
  57. package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
  58. package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
  59. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
  60. package/src/css/svg/mapboxgl-ctrl-geolocate-background.svg +3 -0
  61. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +3 -0
  62. package/src/css/svg/mapboxgl-ctrl-logo-compact.svg +2 -0
  63. package/src/css/svg/mapboxgl-ctrl-logo.svg +1 -0
  64. package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
  65. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
  66. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
  67. package/src/data/array_types.js +1138 -0
  68. package/src/data/bucket/circle_attributes.js +5 -0
  69. package/src/data/bucket/circle_bucket.js +118 -0
  70. package/src/data/bucket/fill_attributes.js +5 -0
  71. package/src/data/bucket/fill_bucket.js +166 -0
  72. package/src/data/bucket/fill_extrusion_attributes.js +11 -0
  73. package/src/data/bucket/fill_extrusion_bucket.js +247 -0
  74. package/src/data/bucket/heatmap_bucket.js +12 -0
  75. package/src/data/bucket/line_attributes.js +11 -0
  76. package/src/data/bucket/line_bucket.js +625 -0
  77. package/src/data/bucket/pattern_attributes.js +9 -0
  78. package/src/data/bucket/pattern_bucket_features.js +44 -0
  79. package/src/data/bucket/symbol_attributes.js +95 -0
  80. package/src/data/bucket/symbol_bucket.js +697 -0
  81. package/src/data/bucket.js +53 -0
  82. package/src/data/dem_data.js +126 -0
  83. package/src/data/extent.js +17 -0
  84. package/src/data/feature_index.js +254 -0
  85. package/src/data/index_array_type.js +14 -0
  86. package/src/data/load_geometry.js +42 -0
  87. package/src/data/pos_attributes.js +3 -0
  88. package/src/data/program_configuration.js +782 -0
  89. package/src/data/raster_bounds_attributes.js +6 -0
  90. package/src/data/segment.js +63 -0
  91. package/src/geo/coordinate.js +78 -0
  92. package/src/geo/lng_lat.js +129 -0
  93. package/src/geo/lng_lat_bounds.js +253 -0
  94. package/src/geo/transform.js +605 -0
  95. package/src/gl/color_mode.js +21 -0
  96. package/src/gl/context.js +193 -0
  97. package/src/gl/cull_face_mode.js +22 -0
  98. package/src/gl/depth_mode.js +18 -0
  99. package/src/gl/framebuffer.js +28 -0
  100. package/src/gl/index_buffer.js +52 -0
  101. package/src/gl/stencil_mode.js +17 -0
  102. package/src/gl/types.js +0 -0
  103. package/src/gl/value.js +676 -0
  104. package/src/gl/vertex_buffer.js +101 -0
  105. package/src/index.js +50 -0
  106. package/src/render/draw_background.js +60 -0
  107. package/src/render/draw_circle.js +55 -0
  108. package/src/render/draw_collision_debug.js +45 -0
  109. package/src/render/draw_debug.js +429 -0
  110. package/src/render/draw_fill.js +143 -0
  111. package/src/render/draw_fill_extrusion.js +101 -0
  112. package/src/render/draw_heatmap.js +159 -0
  113. package/src/render/draw_hillshade.js +144 -0
  114. package/src/render/draw_line.js +99 -0
  115. package/src/render/draw_raster.js +151 -0
  116. package/src/render/draw_symbol.js +231 -0
  117. package/src/render/glyph_atlas.js +55 -0
  118. package/src/render/glyph_manager.js +145 -0
  119. package/src/render/image_atlas.js +97 -0
  120. package/src/render/image_manager.js +183 -0
  121. package/src/render/line_atlas.js +139 -0
  122. package/src/render/painter.js +483 -0
  123. package/src/render/program/background_program.js +46 -0
  124. package/src/render/program/circle_program.js +40 -0
  125. package/src/render/program/clipping_mask_program.js +11 -0
  126. package/src/render/program/collision_program.js +28 -0
  127. package/src/render/program/debug_program.js +13 -0
  128. package/src/render/program/fill_extrusion_program.js +76 -0
  129. package/src/render/program/fill_program.js +60 -0
  130. package/src/render/program/heatmap_program.js +46 -0
  131. package/src/render/program/hillshade_program.js +77 -0
  132. package/src/render/program/line_program.js +119 -0
  133. package/src/render/program/pattern.js +57 -0
  134. package/src/render/program/program_uniforms.js +46 -0
  135. package/src/render/program/raster_program.js +50 -0
  136. package/src/render/program/symbol_program.js +112 -0
  137. package/src/render/program.js +133 -0
  138. package/src/render/texture.js +88 -0
  139. package/src/render/tile_mask.js +108 -0
  140. package/src/render/uniform_binding.js +129 -0
  141. package/src/render/vertex_array_object.js +155 -0
  142. package/src/shaders/README.md +42 -0
  143. package/src/shaders/_prelude.fragment.glsl +17 -0
  144. package/src/shaders/_prelude.vertex.glsl +73 -0
  145. package/src/shaders/background.fragment.glsl +10 -0
  146. package/src/shaders/background.vertex.glsl +7 -0
  147. package/src/shaders/background_pattern.fragment.glsl +28 -0
  148. package/src/shaders/background_pattern.vertex.glsl +20 -0
  149. package/src/shaders/circle.fragment.glsl +39 -0
  150. package/src/shaders/circle.vertex.glsl +63 -0
  151. package/src/shaders/clipping_mask.fragment.glsl +3 -0
  152. package/src/shaders/clipping_mask.vertex.glsl +7 -0
  153. package/src/shaders/collision_box.fragment.glsl +21 -0
  154. package/src/shaders/collision_box.vertex.glsl +26 -0
  155. package/src/shaders/collision_circle.fragment.glsl +34 -0
  156. package/src/shaders/collision_circle.vertex.glsl +36 -0
  157. package/src/shaders/debug.fragment.glsl +5 -0
  158. package/src/shaders/debug.vertex.glsl +7 -0
  159. package/src/shaders/encode_attribute.js +19 -0
  160. package/src/shaders/fill.fragment.glsl +13 -0
  161. package/src/shaders/fill.vertex.glsl +13 -0
  162. package/src/shaders/fill_extrusion.fragment.glsl +16 -0
  163. package/src/shaders/fill_extrusion.vertex.glsl +66 -0
  164. package/src/shaders/fill_extrusion_pattern.fragment.glsl +41 -0
  165. package/src/shaders/fill_extrusion_pattern.vertex.glsl +76 -0
  166. package/src/shaders/fill_outline.fragment.glsl +17 -0
  167. package/src/shaders/fill_outline.vertex.glsl +17 -0
  168. package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
  169. package/src/shaders/fill_outline_pattern.vertex.glsl +41 -0
  170. package/src/shaders/fill_pattern.fragment.glsl +36 -0
  171. package/src/shaders/fill_pattern.vertex.glsl +36 -0
  172. package/src/shaders/heatmap.fragment.glsl +21 -0
  173. package/src/shaders/heatmap.vertex.glsl +53 -0
  174. package/src/shaders/heatmap_texture.fragment.glsl +14 -0
  175. package/src/shaders/heatmap_texture.vertex.glsl +11 -0
  176. package/src/shaders/hillshade.fragment.glsl +52 -0
  177. package/src/shaders/hillshade.vertex.glsl +11 -0
  178. package/src/shaders/hillshade_prepare.fragment.glsl +72 -0
  179. package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
  180. package/src/shaders/index.js +194 -0
  181. package/src/shaders/line.fragment.glsl +28 -0
  182. package/src/shaders/line.vertex.glsl +84 -0
  183. package/src/shaders/line_gradient.fragment.glsl +34 -0
  184. package/src/shaders/line_gradient.vertex.glsl +84 -0
  185. package/src/shaders/line_pattern.fragment.glsl +69 -0
  186. package/src/shaders/line_pattern.vertex.glsl +88 -0
  187. package/src/shaders/line_sdf.fragment.glsl +44 -0
  188. package/src/shaders/line_sdf.vertex.glsl +95 -0
  189. package/src/shaders/raster.fragment.glsl +52 -0
  190. package/src/shaders/raster.vertex.glsl +21 -0
  191. package/src/shaders/symbol_icon.fragment.glsl +17 -0
  192. package/src/shaders/symbol_icon.vertex.glsl +91 -0
  193. package/src/shaders/symbol_sdf.fragment.glsl +50 -0
  194. package/src/shaders/symbol_sdf.vertex.glsl +117 -0
  195. package/src/source/geojson_source.js +267 -0
  196. package/src/source/geojson_worker_source.js +210 -0
  197. package/src/source/geojson_wrapper.js +67 -0
  198. package/src/source/image_source.js +213 -0
  199. package/src/source/load_tilejson.js +40 -0
  200. package/src/source/pixels_to_tile_units.js +17 -0
  201. package/src/source/query_features.js +198 -0
  202. package/src/source/raster_dem_tile_source.js +140 -0
  203. package/src/source/raster_dem_tile_worker_source.js +26 -0
  204. package/src/source/raster_tile_source.js +126 -0
  205. package/src/source/rtl_text_plugin.js +63 -0
  206. package/src/source/source.js +75 -0
  207. package/src/source/source_cache.js +794 -0
  208. package/src/source/source_state.js +55 -0
  209. package/src/source/tile.js +332 -0
  210. package/src/source/tile_bounds.js +40 -0
  211. package/src/source/tile_cache.js +122 -0
  212. package/src/source/tile_id.js +150 -0
  213. package/src/source/vector_tile_source.js +144 -0
  214. package/src/source/vector_tile_worker_source.js +126 -0
  215. package/src/source/worker.js +175 -0
  216. package/src/source/worker_source.js +14 -0
  217. package/src/source/worker_tile.js +199 -0
  218. package/src/style/create_style_layer.js +25 -0
  219. package/src/style/evaluation_parameters.js +45 -0
  220. package/src/style/light.js +112 -0
  221. package/src/style/load_glyph_range.js +17 -0
  222. package/src/style/load_sprite.js +26 -0
  223. package/src/style/parse_glyph_pbf.js +45 -0
  224. package/src/style/pauseable_placement.js +88 -0
  225. package/src/style/properties.js +691 -0
  226. package/src/style/query_utils.js +39 -0
  227. package/src/style/style.js +955 -0
  228. package/src/style/style_layer/background_style_layer.js +11 -0
  229. package/src/style/style_layer/background_style_layer_properties.js +25 -0
  230. package/src/style/style_layer/circle_style_layer.js +93 -0
  231. package/src/style/style_layer/circle_style_layer_properties.js +76 -0
  232. package/src/style/style_layer/fill_extrusion_style_layer.js +194 -0
  233. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +56 -0
  234. package/src/style/style_layer/fill_style_layer.js +46 -0
  235. package/src/style/style_layer/fill_style_layer_properties.js +45 -0
  236. package/src/style/style_layer/heatmap_style_layer.js +51 -0
  237. package/src/style/style_layer/heatmap_style_layer_properties.js +52 -0
  238. package/src/style/style_layer/hillshade_style_layer.js +15 -0
  239. package/src/style/style_layer/hillshade_style_layer_properties.js +43 -0
  240. package/src/style/style_layer/line_style_layer.js +129 -0
  241. package/src/style/style_layer/line_style_layer_properties.js +104 -0
  242. package/src/style/style_layer/raster_style_layer.js +11 -0
  243. package/src/style/style_layer/raster_style_layer_properties.js +55 -0
  244. package/src/style/style_layer/symbol_style_layer.js +66 -0
  245. package/src/style/style_layer/symbol_style_layer_properties.js +288 -0
  246. package/src/style/style_layer.js +183 -0
  247. package/src/style/style_layer_index.js +61 -0
  248. package/src/style/zoom_history.js +36 -0
  249. package/src/style-spec/deref.js +51 -0
  250. package/src/style-spec/error/parsing_error.js +8 -0
  251. package/src/style-spec/error/validation_error.js +10 -0
  252. package/src/style-spec/expression/compound_expression.js +118 -0
  253. package/src/style-spec/expression/definitions/array.js +82 -0
  254. package/src/style-spec/expression/definitions/assertion.js +69 -0
  255. package/src/style-spec/expression/definitions/at.js +57 -0
  256. package/src/style-spec/expression/definitions/case.js +73 -0
  257. package/src/style-spec/expression/definitions/coalesce.js +68 -0
  258. package/src/style-spec/expression/definitions/coercion.js +96 -0
  259. package/src/style-spec/expression/definitions/collator.js +102 -0
  260. package/src/style-spec/expression/definitions/equals.js +93 -0
  261. package/src/style-spec/expression/definitions/index.js +407 -0
  262. package/src/style-spec/expression/definitions/interpolate.js +235 -0
  263. package/src/style-spec/expression/definitions/length.js +54 -0
  264. package/src/style-spec/expression/definitions/let.js +60 -0
  265. package/src/style-spec/expression/definitions/literal.js +64 -0
  266. package/src/style-spec/expression/definitions/match.js +142 -0
  267. package/src/style-spec/expression/definitions/step.js +116 -0
  268. package/src/style-spec/expression/definitions/var.js +38 -0
  269. package/src/style-spec/expression/evaluation_context.js +35 -0
  270. package/src/style-spec/expression/index.js +329 -0
  271. package/src/style-spec/expression/is_constant.js +63 -0
  272. package/src/style-spec/expression/parsing_context.js +213 -0
  273. package/src/style-spec/expression/parsing_error.js +9 -0
  274. package/src/style-spec/expression/runtime_error.js +12 -0
  275. package/src/style-spec/expression/scope.js +34 -0
  276. package/src/style-spec/expression/stops.js +37 -0
  277. package/src/style-spec/expression/types.js +77 -0
  278. package/src/style-spec/expression/values.js +126 -0
  279. package/src/style-spec/feature_filter/README.md +55 -0
  280. package/src/style-spec/feature_filter/index.js +158 -0
  281. package/src/style-spec/function/convert.js +256 -0
  282. package/src/style-spec/function/index.js +299 -0
  283. package/src/style-spec/group_by_layout.js +68 -0
  284. package/src/style-spec/reference/v8.json +5356 -0
  285. package/src/style-spec/util/color.js +73 -0
  286. package/src/style-spec/util/color_spaces.js +128 -0
  287. package/src/style-spec/util/eval_support.js +8 -0
  288. package/src/style-spec/util/get_type.js +18 -0
  289. package/src/style-spec/util/interpolate.js +21 -0
  290. package/src/style-spec/util/properties.js +17 -0
  291. package/src/style-spec/util/ref_properties.js +1 -0
  292. package/src/style-spec/util/result.js +19 -0
  293. package/src/symbol/anchor.js +21 -0
  294. package/src/symbol/check_max_angle.js +75 -0
  295. package/src/symbol/clip_line.js +73 -0
  296. package/src/symbol/collision_feature.js +230 -0
  297. package/src/symbol/collision_index.js +379 -0
  298. package/src/symbol/cross_tile_symbol_index.js +270 -0
  299. package/src/symbol/get_anchors.js +177 -0
  300. package/src/symbol/grid_index.js +318 -0
  301. package/src/symbol/mergelines.js +75 -0
  302. package/src/symbol/opacity_state.js +21 -0
  303. package/src/symbol/placement.js +563 -0
  304. package/src/symbol/projection.js +601 -0
  305. package/src/symbol/quads.js +173 -0
  306. package/src/symbol/shaping.js +347 -0
  307. package/src/symbol/symbol_layout.js +519 -0
  308. package/src/symbol/symbol_size.js +110 -0
  309. package/src/symbol/transform_text.js +16 -0
  310. package/src/ui/anchor.js +24 -0
  311. package/src/ui/bind_handlers.js +199 -0
  312. package/src/ui/camera.js +954 -0
  313. package/src/ui/events.js +210 -0
  314. package/src/ui/handler/box_zoom.js +151 -0
  315. package/src/ui/handler/dblclick_zoom.js +91 -0
  316. package/src/ui/handler/drag_pan.js +285 -0
  317. package/src/ui/handler/drag_rotate.js +290 -0
  318. package/src/ui/handler/frame.js +28 -0
  319. package/src/ui/handler/inertia.js +45 -0
  320. package/src/ui/handler/keyboard.js +148 -0
  321. package/src/ui/handler/scroll_zoom.js +284 -0
  322. package/src/ui/handler/touch_zoom_rotate.js +263 -0
  323. package/src/ui/map.js +1645 -0
  324. package/src/util/actor.js +104 -0
  325. package/src/util/async.js +23 -0
  326. package/src/util/browser.js +61 -0
  327. package/src/util/callback.js +26 -0
  328. package/src/util/classify_rings.js +43 -0
  329. package/src/util/color_ramp.js +24 -0
  330. package/src/util/config.js +24 -0
  331. package/src/util/dictionary_coder.js +25 -0
  332. package/src/util/dispatcher.js +68 -0
  333. package/src/util/dom.js +102 -0
  334. package/src/util/evented.js +182 -0
  335. package/src/util/find_pole_of_inaccessibility.js +129 -0
  336. package/src/util/global_worker_pool.js +15 -0
  337. package/src/util/image.js +124 -0
  338. package/src/util/interpolate.js +5 -0
  339. package/src/util/intersection_tests.js +207 -0
  340. package/src/util/is_char_in_unicode_block.js +287 -0
  341. package/src/util/loader/image.js +32 -0
  342. package/src/util/object.js +178 -0
  343. package/src/util/script_detection.js +337 -0
  344. package/src/util/struct_array.js +197 -0
  345. package/src/util/task_queue.js +57 -0
  346. package/src/util/throttle.js +26 -0
  347. package/src/util/tile_cover.js +114 -0
  348. package/src/util/token.js +13 -0
  349. package/src/util/unique_id.js +12 -0
  350. package/src/util/util.js +192 -0
  351. package/src/util/vectortile_to_geojson.js +44 -0
  352. package/src/util/verticalize_punctuation.js +112 -0
  353. package/src/util/warn.js +21 -0
  354. package/src/util/web_worker.js +5 -0
  355. package/src/util/web_worker_transfer.js +228 -0
  356. package/src/util/worker_pool.js +41 -0
@@ -0,0 +1,519 @@
1
+ const Anchor = require('./anchor');
2
+
3
+ const { getAnchors, getCenterAnchor } = require('./get_anchors');
4
+ const clipLine = require('./clip_line');
5
+ const { shapeText, shapeIcon, WritingMode } = require('./shaping');
6
+ const { getGlyphQuads, getIconQuads } = require('./quads');
7
+ const CollisionFeature = require('./collision_feature');
8
+ const warn = require('../util/warn');
9
+ const { allowsVerticalWritingMode, allowsLetterSpacing } = require('../util/script_detection');
10
+ const findPoleOfInaccessibility = require('../util/find_pole_of_inaccessibility');
11
+ const classifyRings = require('../util/classify_rings');
12
+ const EXTENT = require('../data/extent');
13
+ const SymbolBucket = require('../data/bucket/symbol_bucket');
14
+ const EvaluationParameters = require('../style/evaluation_parameters');
15
+
16
+ // The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and
17
+ // `icon-size` at up to three:
18
+ //
19
+ // 1. `text-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `text-size`
20
+ // expressions, and to calculate the box dimensions for icon-text-fit.
21
+ // 2. `icon-size` at the zoom level of the bucket. Used to calculate a per-feature size for source `icon-size`
22
+ // expressions.
23
+ // 3. `text-size` and `icon-size` at the zoom level of the bucket, plus one. Used to calculate collision boxes.
24
+ // 4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.
25
+ // 5. For composite `*-size` expressions: two zoom levels of curve stops that "cover" the zoom level of the
26
+ // bucket. These go into a vertex buffer and are used by the shader to interpolate the size at render time.
27
+ //
28
+ // (1) and (2) are stored in `bucket.layers[0].layout`. The remainder are below.
29
+ //
30
+
31
+ function performSymbolLayout(bucket, glyphMap, glyphPositions, imageMap, imagePositions, showCollisionBoxes) {
32
+ bucket.createArrays();
33
+ bucket.symbolInstances = [];
34
+
35
+ const tileSize = 512 * bucket.overscaling;
36
+ bucket.tilePixelRatio = EXTENT / tileSize;
37
+ bucket.compareText = {};
38
+ bucket.iconsNeedLinear = false;
39
+
40
+ const layout = bucket.layers[0].layout;
41
+ const unevaluatedLayoutValues = bucket.layers[0]._unevaluatedLayout._values;
42
+
43
+ const sizes = {};
44
+
45
+ if (bucket.textSizeData.functionType === 'composite') {
46
+ const { min, max } = bucket.textSizeData.zoomRange;
47
+ sizes.compositeTextSizes = [
48
+ unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(min)),
49
+ unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(max))
50
+ ];
51
+ }
52
+
53
+ if (bucket.iconSizeData.functionType === 'composite') {
54
+ const { min, max } = bucket.iconSizeData.zoomRange;
55
+ sizes.compositeIconSizes = [
56
+ unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(min)),
57
+ unevaluatedLayoutValues['icon-size'].possiblyEvaluate(new EvaluationParameters(max))
58
+ ];
59
+ }
60
+
61
+ sizes.layoutTextSize = unevaluatedLayoutValues['text-size'].possiblyEvaluate(
62
+ new EvaluationParameters(bucket.zoom + 1)
63
+ );
64
+ sizes.layoutIconSize = unevaluatedLayoutValues['icon-size'].possiblyEvaluate(
65
+ new EvaluationParameters(bucket.zoom + 1)
66
+ );
67
+ sizes.textMaxSize = unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18));
68
+
69
+ const oneEm = 24;
70
+ const lineHeight = layout.get('text-line-height') * oneEm;
71
+ const textAlongLine = layout.get('text-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
72
+ const keepUpright = layout.get('text-keep-upright');
73
+
74
+ for (const feature of bucket.features) {
75
+ const fontstack = layout.get('text-font').evaluate(feature, {}).join(',');
76
+ const glyphs = glyphMap[fontstack] || {};
77
+ const glyphPositionMap = glyphPositions[fontstack] || {};
78
+
79
+ const shapedTextOrientations = {};
80
+ const text = feature.text;
81
+ if (text) {
82
+ const textOffset = layout
83
+ .get('text-offset')
84
+ .evaluate(feature, {})
85
+ .map(t => t * oneEm);
86
+ const spacing = layout.get('text-letter-spacing').evaluate(feature, {}) * oneEm;
87
+ const spacingIfAllowed = allowsLetterSpacing(text) ? spacing : 0;
88
+ const textAnchor = layout.get('text-anchor').evaluate(feature, {});
89
+ const textJustify = layout.get('text-justify').evaluate(feature, {});
90
+ const maxWidth =
91
+ layout.get('symbol-placement') === 'point' ? layout.get('text-max-width').evaluate(feature, {}) * oneEm : 0;
92
+
93
+ shapedTextOrientations.horizontal = shapeText(
94
+ text,
95
+ glyphs,
96
+ maxWidth,
97
+ lineHeight,
98
+ textAnchor,
99
+ textJustify,
100
+ spacingIfAllowed,
101
+ textOffset,
102
+ oneEm,
103
+ WritingMode.horizontal
104
+ );
105
+ if (allowsVerticalWritingMode(text) && textAlongLine && keepUpright) {
106
+ shapedTextOrientations.vertical = shapeText(
107
+ text,
108
+ glyphs,
109
+ maxWidth,
110
+ lineHeight,
111
+ textAnchor,
112
+ textJustify,
113
+ spacingIfAllowed,
114
+ textOffset,
115
+ oneEm,
116
+ WritingMode.vertical
117
+ );
118
+ }
119
+ }
120
+
121
+ let shapedIcon;
122
+ if (feature.icon) {
123
+ const image = imageMap[feature.icon];
124
+ if (image) {
125
+ shapedIcon = shapeIcon(
126
+ imagePositions[feature.icon],
127
+ layout.get('icon-offset').evaluate(feature, {}),
128
+ layout.get('icon-anchor').evaluate(feature, {})
129
+ );
130
+ if (bucket.sdfIcons === undefined) {
131
+ bucket.sdfIcons = image.sdf;
132
+ } else if (bucket.sdfIcons !== image.sdf) {
133
+ warn.once('Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer');
134
+ }
135
+ if (image.pixelRatio !== bucket.pixelRatio) {
136
+ bucket.iconsNeedLinear = true;
137
+ } else if (layout.get('icon-rotate').constantOr(1) !== 0) {
138
+ bucket.iconsNeedLinear = true;
139
+ }
140
+ }
141
+ }
142
+
143
+ if (shapedTextOrientations.horizontal || shapedIcon) {
144
+ addFeature(bucket, feature, shapedTextOrientations, shapedIcon, glyphPositionMap, sizes);
145
+ }
146
+ }
147
+
148
+ if (showCollisionBoxes) {
149
+ bucket.generateCollisionDebugBuffers();
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Given a feature and its shaped text and icon data, add a 'symbol
155
+ * instance' for each _possible_ placement of the symbol feature.
156
+ * (At render timePlaceSymbols#place() selects which of these instances to
157
+ * show or hide based on collisions with symbols in other layers.)
158
+ * @private
159
+ */
160
+ function addFeature(bucket, feature, shapedTextOrientations, shapedIcon, glyphPositionMap, sizes) {
161
+ const layoutTextSize = sizes.layoutTextSize.evaluate(feature, {});
162
+ const layoutIconSize = sizes.layoutIconSize.evaluate(feature, {});
163
+
164
+ // To reduce the number of labels that jump around when zooming we need
165
+ // to use a text-size value that is the same for all zoom levels.
166
+ // bucket calculates text-size at a high zoom level so that all tiles can
167
+ // use the same value when calculating anchor positions.
168
+ let textMaxSize = sizes.textMaxSize.evaluate(feature, {});
169
+ if (textMaxSize === undefined) {
170
+ textMaxSize = layoutTextSize;
171
+ }
172
+
173
+ const layout = bucket.layers[0].layout;
174
+ const textOffset = layout.get('text-offset').evaluate(feature, {});
175
+ const iconOffset = layout.get('icon-offset').evaluate(feature, {});
176
+
177
+ const glyphSize = 24;
178
+ const fontScale = layoutTextSize / glyphSize;
179
+ const textBoxScale = bucket.tilePixelRatio * fontScale;
180
+ const textMaxBoxScale = (bucket.tilePixelRatio * textMaxSize) / glyphSize;
181
+ const iconBoxScale = bucket.tilePixelRatio * layoutIconSize;
182
+ const symbolMinDistance = bucket.tilePixelRatio * layout.get('symbol-spacing');
183
+ const textPadding = layout.get('text-padding') * bucket.tilePixelRatio;
184
+ const iconPadding = layout.get('icon-padding') * bucket.tilePixelRatio;
185
+ const textMaxAngle = (layout.get('text-max-angle') / 180) * Math.PI;
186
+ const textAlongLine = layout.get('text-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
187
+ const iconAlongLine = layout.get('icon-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
188
+ const symbolPlacement = layout.get('symbol-placement');
189
+ const textRepeatDistance = symbolMinDistance / 2;
190
+
191
+ const addSymbolAtAnchor = (line, anchor) => {
192
+ if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) {
193
+ // Symbol layers are drawn across tile boundaries, We filter out symbols
194
+ // outside our tile boundaries (which may be included in vector tile buffers)
195
+ // to prevent double-drawing symbols.
196
+ return;
197
+ }
198
+
199
+ bucket.symbolInstances.push(
200
+ addSymbol(
201
+ bucket,
202
+ anchor,
203
+ line,
204
+ shapedTextOrientations,
205
+ shapedIcon,
206
+ bucket.layers[0],
207
+ bucket.collisionBoxArray,
208
+ feature.index,
209
+ feature.sourceLayerIndex,
210
+ bucket.index,
211
+ textBoxScale,
212
+ textPadding,
213
+ textAlongLine,
214
+ textOffset,
215
+ iconBoxScale,
216
+ iconPadding,
217
+ iconAlongLine,
218
+ iconOffset,
219
+ feature,
220
+ glyphPositionMap,
221
+ sizes
222
+ )
223
+ );
224
+ };
225
+
226
+ if (symbolPlacement === 'line') {
227
+ for (const line of clipLine(feature.geometry, 0, 0, EXTENT, EXTENT)) {
228
+ const anchors = getAnchors(
229
+ line,
230
+ symbolMinDistance,
231
+ textMaxAngle,
232
+ shapedTextOrientations.vertical || shapedTextOrientations.horizontal,
233
+ shapedIcon,
234
+ glyphSize,
235
+ textMaxBoxScale,
236
+ bucket.overscaling,
237
+ EXTENT
238
+ );
239
+ for (const anchor of anchors) {
240
+ const shapedText = shapedTextOrientations.horizontal;
241
+ if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {
242
+ addSymbolAtAnchor(line, anchor);
243
+ }
244
+ }
245
+ }
246
+ } else if (symbolPlacement === 'line-center') {
247
+ // No clipping, multiple lines per feature are allowed
248
+ // "lines" with only one point are ignored as in clipLines
249
+ for (const line of feature.geometry) {
250
+ if (line.length > 1) {
251
+ const anchor = getCenterAnchor(
252
+ line,
253
+ textMaxAngle,
254
+ shapedTextOrientations.vertical || shapedTextOrientations.horizontal,
255
+ shapedIcon,
256
+ glyphSize,
257
+ textMaxBoxScale
258
+ );
259
+ if (anchor) {
260
+ addSymbolAtAnchor(line, anchor);
261
+ }
262
+ }
263
+ }
264
+ } else if (feature.type === 'Polygon') {
265
+ for (const polygon of classifyRings(feature.geometry, 0)) {
266
+ // 16 here represents 2 pixels
267
+ const poi = findPoleOfInaccessibility(polygon, 16);
268
+ addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));
269
+ }
270
+ } else if (feature.type === 'LineString') {
271
+ // https://github.com/mapbox/mapbox-gl-js/issues/3808
272
+ for (const line of feature.geometry) {
273
+ addSymbolAtAnchor(line, new Anchor(line[0].x, line[0].y, 0));
274
+ }
275
+ } else if (feature.type === 'Point') {
276
+ for (const points of feature.geometry) {
277
+ for (const point of points) {
278
+ addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));
279
+ }
280
+ }
281
+ }
282
+ }
283
+
284
+ function addTextVertices(
285
+ bucket,
286
+ anchor,
287
+ shapedText,
288
+ layer,
289
+ textAlongLine,
290
+ feature,
291
+ textOffset,
292
+ lineArray,
293
+ writingMode,
294
+ placedTextSymbolIndices,
295
+ glyphPositionMap,
296
+ sizes
297
+ ) {
298
+ const glyphQuads = getGlyphQuads(anchor, shapedText, layer, textAlongLine, feature, glyphPositionMap);
299
+
300
+ const sizeData = bucket.textSizeData;
301
+ let textSizeData = null;
302
+
303
+ if (sizeData.functionType === 'source') {
304
+ textSizeData = [10 * layer.layout.get('text-size').evaluate(feature, {})];
305
+ } else if (sizeData.functionType === 'composite') {
306
+ textSizeData = [
307
+ 10 * sizes.compositeTextSizes[0].evaluate(feature, {}),
308
+ 10 * sizes.compositeTextSizes[1].evaluate(feature, {})
309
+ ];
310
+ }
311
+
312
+ bucket.addSymbols(
313
+ bucket.text,
314
+ glyphQuads,
315
+ textSizeData,
316
+ textOffset,
317
+ textAlongLine,
318
+ feature,
319
+ writingMode,
320
+ anchor,
321
+ lineArray.lineStartIndex,
322
+ lineArray.lineLength
323
+ );
324
+
325
+ // The placedSymbolArray is used at render time in drawTileSymbols
326
+ // These indices allow access to the array at collision detection time
327
+ placedTextSymbolIndices.push(bucket.text.placedSymbolArray.length - 1);
328
+
329
+ return glyphQuads.length * 4;
330
+ }
331
+
332
+ /**
333
+ * Add a single label & icon placement.
334
+ *
335
+ * @private
336
+ */
337
+ function addSymbol(
338
+ bucket,
339
+ anchor,
340
+ line,
341
+ shapedTextOrientations,
342
+ shapedIcon,
343
+ layer,
344
+ collisionBoxArray,
345
+ featureIndex,
346
+ sourceLayerIndex,
347
+ bucketIndex,
348
+ textBoxScale,
349
+ textPadding,
350
+ textAlongLine,
351
+ textOffset,
352
+ iconBoxScale,
353
+ iconPadding,
354
+ iconAlongLine,
355
+ iconOffset,
356
+ feature,
357
+ glyphPositionMap,
358
+ sizes
359
+ ) {
360
+ const lineArray = bucket.addToLineVertexArray(anchor, line);
361
+
362
+ let textCollisionFeature;
363
+ let iconCollisionFeature;
364
+
365
+ let numIconVertices = 0;
366
+ let numGlyphVertices = 0;
367
+ let numVerticalGlyphVertices = 0;
368
+ const key = shapedTextOrientations.horizontal ? shapedTextOrientations.horizontal.text : '';
369
+ const placedTextSymbolIndices = [];
370
+ if (shapedTextOrientations.horizontal) {
371
+ // As a collision approximation, we can use either the vertical or the horizontal version of the feature
372
+ // We're counting on the two versions having similar dimensions
373
+ const textRotate = layer.layout.get('text-rotate').evaluate(feature, {});
374
+ textCollisionFeature = new CollisionFeature(
375
+ collisionBoxArray,
376
+ line,
377
+ anchor,
378
+ featureIndex,
379
+ sourceLayerIndex,
380
+ bucketIndex,
381
+ shapedTextOrientations.horizontal,
382
+ textBoxScale,
383
+ textPadding,
384
+ textAlongLine,
385
+ bucket.overscaling,
386
+ textRotate
387
+ );
388
+ numGlyphVertices += addTextVertices(
389
+ bucket,
390
+ anchor,
391
+ shapedTextOrientations.horizontal,
392
+ layer,
393
+ textAlongLine,
394
+ feature,
395
+ textOffset,
396
+ lineArray,
397
+ shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly,
398
+ placedTextSymbolIndices,
399
+ glyphPositionMap,
400
+ sizes
401
+ );
402
+
403
+ if (shapedTextOrientations.vertical) {
404
+ numVerticalGlyphVertices += addTextVertices(
405
+ bucket,
406
+ anchor,
407
+ shapedTextOrientations.vertical,
408
+ layer,
409
+ textAlongLine,
410
+ feature,
411
+ textOffset,
412
+ lineArray,
413
+ WritingMode.vertical,
414
+ placedTextSymbolIndices,
415
+ glyphPositionMap,
416
+ sizes
417
+ );
418
+ }
419
+ }
420
+
421
+ const textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
422
+ const textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
423
+
424
+ if (shapedIcon) {
425
+ const iconQuads = getIconQuads(
426
+ anchor,
427
+ shapedIcon,
428
+ layer,
429
+ iconAlongLine,
430
+ shapedTextOrientations.horizontal,
431
+ feature
432
+ );
433
+ const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {});
434
+ iconCollisionFeature = new CollisionFeature(
435
+ collisionBoxArray,
436
+ line,
437
+ anchor,
438
+ featureIndex,
439
+ sourceLayerIndex,
440
+ bucketIndex,
441
+ shapedIcon,
442
+ iconBoxScale,
443
+ iconPadding,
444
+ /*align boxes to line*/ false,
445
+ bucket.overscaling,
446
+ iconRotate
447
+ );
448
+
449
+ numIconVertices = iconQuads.length * 4;
450
+
451
+ const sizeData = bucket.iconSizeData;
452
+ let iconSizeData = null;
453
+
454
+ if (sizeData.functionType === 'source') {
455
+ iconSizeData = [10 * layer.layout.get('icon-size').evaluate(feature, {})];
456
+ } else if (sizeData.functionType === 'composite') {
457
+ iconSizeData = [
458
+ 10 * sizes.compositeIconSizes[0].evaluate(feature, {}),
459
+ 10 * sizes.compositeIconSizes[1].evaluate(feature, {})
460
+ ];
461
+ }
462
+
463
+ bucket.addSymbols(
464
+ bucket.icon,
465
+ iconQuads,
466
+ iconSizeData,
467
+ iconOffset,
468
+ iconAlongLine,
469
+ feature,
470
+ false,
471
+ anchor,
472
+ lineArray.lineStartIndex,
473
+ lineArray.lineLength
474
+ );
475
+ }
476
+
477
+ const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
478
+ const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
479
+
480
+ if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS)
481
+ warn.once('Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907');
482
+
483
+ return {
484
+ key,
485
+ textBoxStartIndex,
486
+ textBoxEndIndex,
487
+ iconBoxStartIndex,
488
+ iconBoxEndIndex,
489
+ anchor,
490
+ featureIndex,
491
+ numGlyphVertices,
492
+ numVerticalGlyphVertices,
493
+ numIconVertices,
494
+ placedTextSymbolIndices,
495
+ crossTileID: 0
496
+ };
497
+ }
498
+
499
+ function anchorIsTooClose(bucket, text, repeatDistance, anchor) {
500
+ const compareText = bucket.compareText;
501
+ if (!(text in compareText)) {
502
+ compareText[text] = [];
503
+ } else {
504
+ const otherAnchors = compareText[text];
505
+ for (let k = otherAnchors.length - 1; k >= 0; k--) {
506
+ if (anchor.dist(otherAnchors[k]) < repeatDistance) {
507
+ // If it's within repeatDistance of one anchor, stop looking
508
+ return true;
509
+ }
510
+ }
511
+ }
512
+ // If anchor is not within repeatDistance of any other anchor, add to array
513
+ compareText[text].push(anchor);
514
+ return false;
515
+ }
516
+
517
+ module.exports = {
518
+ performSymbolLayout
519
+ };
@@ -0,0 +1,110 @@
1
+ const { normalizePropertyExpression } = require('../style-spec/expression');
2
+
3
+ const interpolate = require('../util/interpolate');
4
+ const { clamp } = require('../util/util');
5
+ const EvaluationParameters = require('../style/evaluation_parameters');
6
+
7
+ module.exports = { getSizeData, evaluateSizeForFeature, evaluateSizeForZoom };
8
+
9
+ // For {text,icon}-size, get the bucket-level data that will be needed by
10
+ // the painter to set symbol-size-related uniforms
11
+ function getSizeData(tileZoom, value) {
12
+ const { expression } = value;
13
+ if (expression.kind === 'constant') {
14
+ return {
15
+ functionType: 'constant',
16
+ layoutSize: expression.evaluate(new EvaluationParameters(tileZoom + 1))
17
+ };
18
+ }
19
+ if (expression.kind === 'source') {
20
+ return {
21
+ functionType: 'source'
22
+ };
23
+ }
24
+ // calculate covering zoom stops for zoom-dependent values
25
+ const levels = expression.zoomStops;
26
+
27
+ let lower = 0;
28
+ while (lower < levels.length && levels[lower] <= tileZoom) lower++;
29
+ lower = Math.max(0, lower - 1);
30
+ let upper = lower;
31
+ while (upper < levels.length && levels[upper] < tileZoom + 1) upper++;
32
+ upper = Math.min(levels.length - 1, upper);
33
+
34
+ const zoomRange = {
35
+ min: levels[lower],
36
+ max: levels[upper]
37
+ };
38
+
39
+ // We'd like to be able to use CameraExpression or CompositeExpression in these
40
+ // return types rather than ExpressionSpecification, but the former are not
41
+ // transferrable across Web Worker boundaries.
42
+ if (expression.kind === 'composite') {
43
+ return {
44
+ functionType: 'composite',
45
+ zoomRange,
46
+ propertyValue: value.value
47
+ };
48
+ }
49
+ // for camera functions, also save off the function values
50
+ // evaluated at the covering zoom levels
51
+ return {
52
+ functionType: 'camera',
53
+ layoutSize: expression.evaluate(new EvaluationParameters(tileZoom + 1)),
54
+ zoomRange,
55
+ sizeRange: {
56
+ min: expression.evaluate(new EvaluationParameters(zoomRange.min)),
57
+ max: expression.evaluate(new EvaluationParameters(zoomRange.max))
58
+ },
59
+ propertyValue: value.value
60
+ };
61
+ }
62
+
63
+ function evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol) {
64
+ const part = partiallyEvaluatedSize;
65
+ if (sizeData.functionType === 'source') {
66
+ return symbol.lowerSize / 10;
67
+ }
68
+ if (sizeData.functionType === 'composite') {
69
+ return interpolate(symbol.lowerSize / 10, symbol.upperSize / 10, part.uSizeT);
70
+ }
71
+ return part.uSize;
72
+ }
73
+
74
+ function evaluateSizeForZoom(sizeData, currentZoom, property) {
75
+ if (sizeData.functionType === 'constant') {
76
+ return {
77
+ uSizeT: 0,
78
+ uSize: sizeData.layoutSize
79
+ };
80
+ }
81
+ if (sizeData.functionType === 'source') {
82
+ return {
83
+ uSizeT: 0,
84
+ uSize: 0
85
+ };
86
+ }
87
+ if (sizeData.functionType === 'camera') {
88
+ const { propertyValue, zoomRange, sizeRange } = sizeData;
89
+ const expression = normalizePropertyExpression(propertyValue, property.specification);
90
+
91
+ // Even though we could get the exact value of the camera function
92
+ // at z = tr.zoom, we intentionally do not: instead, we interpolate
93
+ // between the camera function values at a pair of zoom stops covering
94
+ // [tileZoom, tileZoom + 1] in order to be consistent with this
95
+ // restriction on composite functions
96
+ const t = clamp(expression.interpolationFactor(currentZoom, zoomRange.min, zoomRange.max), 0, 1);
97
+
98
+ return {
99
+ uSizeT: 0,
100
+ uSize: sizeRange.min + t * (sizeRange.max - sizeRange.min)
101
+ };
102
+ }
103
+ const { propertyValue, zoomRange } = sizeData;
104
+ const expression = normalizePropertyExpression(propertyValue, property.specification);
105
+
106
+ return {
107
+ uSizeT: clamp(expression.interpolationFactor(currentZoom, zoomRange.min, zoomRange.max), 0, 1),
108
+ uSize: 0
109
+ };
110
+ }
@@ -0,0 +1,16 @@
1
+ const { plugin: rtlTextPlugin } = require('../source/rtl_text_plugin');
2
+
3
+ module.exports = function (text, layer, feature) {
4
+ const transform = layer.layout.get('text-transform').evaluate(feature, {});
5
+ if (transform === 'uppercase') {
6
+ text = text.toLocaleUpperCase();
7
+ } else if (transform === 'lowercase') {
8
+ text = text.toLocaleLowerCase();
9
+ }
10
+
11
+ if (rtlTextPlugin.applyArabicShaping) {
12
+ text = rtlTextPlugin.applyArabicShaping(text);
13
+ }
14
+
15
+ return text;
16
+ };
@@ -0,0 +1,24 @@
1
+ const anchorTranslate = {
2
+ center: 'translate(-50%,-50%)',
3
+ top: 'translate(-50%,0)',
4
+ 'top-left': 'translate(0,0)',
5
+ 'top-right': 'translate(-100%,0)',
6
+ bottom: 'translate(-50%,-100%)',
7
+ 'bottom-left': 'translate(0,-100%)',
8
+ 'bottom-right': 'translate(-100%,-100%)',
9
+ left: 'translate(0,-50%)',
10
+ right: 'translate(-100%,-50%)'
11
+ };
12
+
13
+ function applyAnchorClass(element, anchor, prefix) {
14
+ const classList = element.classList;
15
+ for (const key in anchorTranslate) {
16
+ classList.remove(`mapboxgl-${prefix}-anchor-${key}`);
17
+ }
18
+ classList.add(`mapboxgl-${prefix}-anchor-${anchor}`);
19
+ }
20
+
21
+ module.exports = {
22
+ anchorTranslate,
23
+ applyAnchorClass
24
+ };