@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,183 @@
1
+ const { filterObject } = require('../util/object');
2
+
3
+ const { Evented } = require('../util/evented');
4
+ const { Layout, Transitionable, PossiblyEvaluatedPropertyValue } = require('./properties');
5
+ const { supportsPropertyExpression } = require('../style-spec/util/properties');
6
+
7
+ const TRANSITION_SUFFIX = '-transition';
8
+
9
+ class StyleLayer extends Evented {
10
+ constructor(layer, properties) {
11
+ super();
12
+
13
+ this.id = layer.id;
14
+ this.metadata = layer.metadata;
15
+ this.type = layer.type;
16
+ this.minzoom = layer.minzoom;
17
+ this.maxzoom = layer.maxzoom;
18
+ this.visibility = 'visible';
19
+ this.paint = {};
20
+ this.layout = {};
21
+
22
+ if (layer.type !== 'background') {
23
+ this.source = layer.source;
24
+ this.sourceLayer = layer['source-layer'];
25
+ this.filter = layer.filter;
26
+ }
27
+
28
+ this._featureFilter = () => true;
29
+
30
+ if (properties.layout) {
31
+ this._unevaluatedLayout = new Layout(properties.layout);
32
+ }
33
+
34
+ this._transitionablePaint = new Transitionable(properties.paint);
35
+
36
+ for (const property in layer.paint) {
37
+ this.setPaintProperty(property, layer.paint[property]);
38
+ }
39
+ for (const property in layer.layout) {
40
+ this.setLayoutProperty(property, layer.layout[property]);
41
+ }
42
+
43
+ this._transitioningPaint = this._transitionablePaint.untransitioned();
44
+ }
45
+
46
+ getCrossfadeParameters() {
47
+ return this._crossfadeParameters;
48
+ }
49
+
50
+ getLayoutProperty(name) {
51
+ if (name === 'visibility') {
52
+ return this.visibility;
53
+ }
54
+
55
+ return this._unevaluatedLayout.getValue(name);
56
+ }
57
+
58
+ setLayoutProperty(name, value) {
59
+ if (name === 'visibility') {
60
+ this.visibility = value === 'none' ? value : 'visible';
61
+ return;
62
+ }
63
+
64
+ this._unevaluatedLayout.setValue(name, value);
65
+ }
66
+
67
+ getPaintProperty(name) {
68
+ if (name.endsWith(TRANSITION_SUFFIX)) {
69
+ return this._transitionablePaint.getTransition(name.slice(0, -TRANSITION_SUFFIX.length));
70
+ }
71
+ return this._transitionablePaint.getValue(name);
72
+ }
73
+
74
+ setPaintProperty(name, value) {
75
+ if (name.endsWith(TRANSITION_SUFFIX)) {
76
+ this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), value || undefined);
77
+ return false;
78
+ }
79
+ // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas
80
+ // so a call to _updateLayer is necessary, and we return true from this function so it gets called in
81
+ // Style#setPaintProperty
82
+ const prop = this._transitionablePaint._values[name];
83
+ const newCrossFadedValue =
84
+ prop.property.specification['property-type'] === 'cross-faded-data-driven' && !prop.value.value && value;
85
+ const wasDataDriven = this._transitionablePaint._values[name].value.isDataDriven();
86
+ this._transitionablePaint.setValue(name, value);
87
+ const isDataDriven = this._transitionablePaint._values[name].value.isDataDriven();
88
+ this._handleSpecialPaintPropertyUpdate(name);
89
+ return isDataDriven || wasDataDriven || newCrossFadedValue;
90
+ }
91
+
92
+ _handleSpecialPaintPropertyUpdate() {
93
+ // No-op; can be overridden by derived classes.
94
+ }
95
+
96
+ isHidden(zoom) {
97
+ if (this.minzoom && zoom < this.minzoom) return true;
98
+ if (this.maxzoom && zoom >= this.maxzoom) return true;
99
+ return this.visibility === 'none';
100
+ }
101
+
102
+ updateTransitions(parameters) {
103
+ this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);
104
+ }
105
+
106
+ hasTransition() {
107
+ return this._transitioningPaint.hasTransition();
108
+ }
109
+
110
+ recalculate(parameters) {
111
+ if (parameters.getCrossfadeParameters) {
112
+ this._crossfadeParameters = parameters.getCrossfadeParameters();
113
+ }
114
+ if (this._unevaluatedLayout) {
115
+ this.layout = this._unevaluatedLayout.possiblyEvaluate(parameters);
116
+ }
117
+
118
+ this.paint = this._transitioningPaint.possiblyEvaluate(parameters);
119
+ }
120
+
121
+ serialize() {
122
+ const output = {
123
+ id: this.id,
124
+ type: this.type,
125
+ source: this.source,
126
+ 'source-layer': this.sourceLayer,
127
+ metadata: this.metadata,
128
+ minzoom: this.minzoom,
129
+ maxzoom: this.maxzoom,
130
+ filter: this.filter,
131
+ layout: this._unevaluatedLayout?.serialize(),
132
+ paint: this._transitionablePaint?.serialize()
133
+ };
134
+
135
+ if (this.visibility === 'none') {
136
+ output.layout = output.layout || {};
137
+ output.layout.visibility = 'none';
138
+ }
139
+
140
+ return filterObject(output, (value, key) => {
141
+ return (
142
+ value !== undefined &&
143
+ !(key === 'layout' && !Object.keys(value).length) &&
144
+ !(key === 'paint' && !Object.keys(value).length)
145
+ );
146
+ });
147
+ }
148
+
149
+ is3D() {
150
+ return false;
151
+ }
152
+
153
+ isTileClipped() {
154
+ return false;
155
+ }
156
+
157
+ hasOffscreenPass() {
158
+ return false;
159
+ }
160
+
161
+ resize() {
162
+ // noop
163
+ }
164
+
165
+ isStateDependent() {
166
+ for (const property in this.paint._values) {
167
+ const value = this.paint.get(property);
168
+ if (
169
+ !(value instanceof PossiblyEvaluatedPropertyValue) ||
170
+ !supportsPropertyExpression(value.property.specification)
171
+ ) {
172
+ continue;
173
+ }
174
+
175
+ if ((value.value.kind === 'source' || value.value.kind === 'composite') && value.value.isStateDependent) {
176
+ return true;
177
+ }
178
+ }
179
+ return false;
180
+ }
181
+ }
182
+
183
+ module.exports = StyleLayer;
@@ -0,0 +1,61 @@
1
+ const createStyleLayer = require('./create_style_layer');
2
+
3
+ const { values } = require('../util/object');
4
+ const featureFilter = require('../style-spec/feature_filter');
5
+ const groupByLayout = require('../style-spec/group_by_layout');
6
+
7
+ class StyleLayerIndex {
8
+ constructor(layerConfigs) {
9
+ if (layerConfigs) {
10
+ this.replace(layerConfigs);
11
+ }
12
+ }
13
+
14
+ replace(layerConfigs) {
15
+ this._layerConfigs = {};
16
+ this._layers = {};
17
+ this.update(layerConfigs, []);
18
+ }
19
+
20
+ update(layerConfigs, removedIds) {
21
+ for (const layerConfig of layerConfigs) {
22
+ this._layerConfigs[layerConfig.id] = layerConfig;
23
+
24
+ const layer = (this._layers[layerConfig.id] = createStyleLayer(layerConfig));
25
+ layer._featureFilter = featureFilter(layer.filter);
26
+ }
27
+ for (const id of removedIds) {
28
+ delete this._layerConfigs[id];
29
+ delete this._layers[id];
30
+ }
31
+
32
+ this.familiesBySource = {};
33
+
34
+ const groups = groupByLayout(values(this._layerConfigs));
35
+
36
+ for (const layerConfigs of groups) {
37
+ const layers = layerConfigs.map(layerConfig => this._layers[layerConfig.id]);
38
+
39
+ const layer = layers[0];
40
+ if (layer.visibility === 'none') {
41
+ continue;
42
+ }
43
+
44
+ const sourceId = layer.source || '';
45
+ let sourceGroup = this.familiesBySource[sourceId];
46
+ if (!sourceGroup) {
47
+ sourceGroup = this.familiesBySource[sourceId] = {};
48
+ }
49
+
50
+ const sourceLayerId = layer.sourceLayer || '_geojsonTileLayer';
51
+ let sourceLayerFamilies = sourceGroup[sourceLayerId];
52
+ if (!sourceLayerFamilies) {
53
+ sourceLayerFamilies = sourceGroup[sourceLayerId] = [];
54
+ }
55
+
56
+ sourceLayerFamilies.push(layers);
57
+ }
58
+ }
59
+ }
60
+
61
+ module.exports = StyleLayerIndex;
@@ -0,0 +1,36 @@
1
+ class ZoomHistory {
2
+ constructor() {
3
+ this.first = true;
4
+ }
5
+
6
+ update(z, now) {
7
+ const floorZ = Math.floor(z);
8
+
9
+ if (this.first) {
10
+ this.first = false;
11
+ this.lastIntegerZoom = floorZ;
12
+ this.lastIntegerZoomTime = 0;
13
+ this.lastZoom = z;
14
+ this.lastFloorZoom = floorZ;
15
+ return true;
16
+ }
17
+
18
+ if (this.lastFloorZoom > floorZ) {
19
+ this.lastIntegerZoom = floorZ + 1;
20
+ this.lastIntegerZoomTime = now;
21
+ } else if (this.lastFloorZoom < floorZ) {
22
+ this.lastIntegerZoom = floorZ;
23
+ this.lastIntegerZoomTime = now;
24
+ }
25
+
26
+ if (z !== this.lastZoom) {
27
+ this.lastZoom = z;
28
+ this.lastFloorZoom = floorZ;
29
+ return true;
30
+ }
31
+
32
+ return false;
33
+ }
34
+ }
35
+
36
+ module.exports = ZoomHistory;
@@ -0,0 +1,51 @@
1
+ const refProperties = require('./util/ref_properties');
2
+
3
+ function deref(layer, parent) {
4
+ const result = {};
5
+
6
+ for (const k in layer) {
7
+ if (k !== 'ref') {
8
+ result[k] = layer[k];
9
+ }
10
+ }
11
+
12
+ refProperties.forEach(k => {
13
+ if (k in parent) {
14
+ result[k] = parent[k];
15
+ }
16
+ });
17
+
18
+ return result;
19
+ }
20
+
21
+ module.exports = derefLayers;
22
+
23
+ /**
24
+ * Given an array of layers, some of which may contain `ref` properties
25
+ * whose value is the `id` of another property, return a new array where
26
+ * such layers have been augmented with the 'type', 'source', etc. properties
27
+ * from the parent layer, and the `ref` property has been removed.
28
+ *
29
+ * The input is not modified. The output may contain references to portions
30
+ * of the input.
31
+ *
32
+ * @private
33
+ * @param {Array<Layer>} layers
34
+ * @returns {Array<Layer>}
35
+ */
36
+ function derefLayers(layers) {
37
+ layers = layers.slice();
38
+
39
+ const map = Object.create(null);
40
+ for (let i = 0; i < layers.length; i++) {
41
+ map[layers[i].id] = layers[i];
42
+ }
43
+
44
+ for (let i = 0; i < layers.length; i++) {
45
+ if ('ref' in layers[i]) {
46
+ layers[i] = deref(layers[i], map[layers[i].ref]);
47
+ }
48
+ }
49
+
50
+ return layers;
51
+ }
@@ -0,0 +1,8 @@
1
+ function ParsingError(error) {
2
+ this.error = error;
3
+ this.message = error.message;
4
+ const match = error.message.match(/line (\d+)/);
5
+ this.line = match ? Number.parseInt(match[1], 10) : 0;
6
+ }
7
+
8
+ module.exports = ParsingError;
@@ -0,0 +1,10 @@
1
+ module.exports = class ValidationError {
2
+ constructor(key, value, message, identifier) {
3
+ this.message = (key ? `${key}: ` : '') + message;
4
+ if (identifier) this.identifier = identifier;
5
+
6
+ if (value?.__line__) {
7
+ this.line = value.__line__;
8
+ }
9
+ }
10
+ };
@@ -0,0 +1,118 @@
1
+ const { toString } = require('./types');
2
+
3
+ const assert = require('assert');
4
+
5
+ class CompoundExpression {
6
+ constructor(name, type, evaluate, args) {
7
+ this.name = name;
8
+ this.type = type;
9
+ this._evaluate = evaluate;
10
+ this.args = args;
11
+ }
12
+
13
+ evaluate(ctx) {
14
+ return this._evaluate(ctx, this.args);
15
+ }
16
+
17
+ eachChild(fn) {
18
+ this.args.forEach(fn);
19
+ }
20
+
21
+ possibleOutputs() {
22
+ return [undefined];
23
+ }
24
+
25
+ serialize() {
26
+ return [this.name].concat(this.args.map(arg => arg.serialize()));
27
+ }
28
+
29
+ static parse(args, context) {
30
+ const ParsingContext = require('./parsing_context');
31
+
32
+ const op = args[0];
33
+ const definition = CompoundExpression.definitions[op];
34
+ if (!definition) {
35
+ return context.error(`Unknown expression "${op}". If you wanted a literal array, use ["literal", [...]].`, 0);
36
+ }
37
+
38
+ // Now check argument types against each signature
39
+ const type = Array.isArray(definition) ? definition[0] : definition.type;
40
+
41
+ const availableOverloads = Array.isArray(definition) ? [[definition[1], definition[2]]] : definition.overloads;
42
+
43
+ const overloads = availableOverloads.filter(
44
+ ([signature]) =>
45
+ !Array.isArray(signature) || // varags
46
+ signature.length === args.length - 1 // correct param count
47
+ );
48
+
49
+ // First parse all the args
50
+ const parsedArgs = [];
51
+ for (let i = 1; i < args.length; i++) {
52
+ const arg = args[i];
53
+ let expected;
54
+ if (overloads.length === 1) {
55
+ const params = overloads[0][0];
56
+ expected = Array.isArray(params) ? params[i - 1] : params.type;
57
+ }
58
+ const parsed = context.parse(arg, 1 + parsedArgs.length, expected);
59
+ if (!parsed) return null;
60
+ parsedArgs.push(parsed);
61
+ }
62
+
63
+ let signatureContext = null;
64
+
65
+ for (const [params, evaluate] of overloads) {
66
+ // Use a fresh context for each attempted signature so that, if
67
+ // we eventually succeed, we haven't polluted `context.errors`.
68
+ signatureContext = new ParsingContext(context.registry, context.path, null, context.scope);
69
+
70
+ if (Array.isArray(params)) {
71
+ if (params.length !== parsedArgs.length) {
72
+ signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);
73
+ continue;
74
+ }
75
+ }
76
+
77
+ for (let i = 0; i < parsedArgs.length; i++) {
78
+ const expected = Array.isArray(params) ? params[i] : params.type;
79
+ const arg = parsedArgs[i];
80
+ signatureContext.concat(i + 1).checkSubtype(expected, arg.type);
81
+ }
82
+
83
+ if (signatureContext.errors.length === 0) {
84
+ return new CompoundExpression(op, type, evaluate, parsedArgs);
85
+ }
86
+ }
87
+
88
+ assert(!signatureContext || signatureContext.errors.length > 0);
89
+
90
+ if (overloads.length === 1) {
91
+ context.errors.push.apply(context.errors, signatureContext.errors);
92
+ } else {
93
+ const expected = overloads.length ? overloads : availableOverloads;
94
+ const signatures = expected.map(([params]) => stringifySignature(params)).join(' | ');
95
+ const actualTypes = parsedArgs.map(arg => toString(arg.type)).join(', ');
96
+ context.error(`Expected arguments of type ${signatures}, but found (${actualTypes}) instead.`);
97
+ }
98
+
99
+ return null;
100
+ }
101
+
102
+ static register(registry, definitions) {
103
+ assert(!CompoundExpression.definitions);
104
+ CompoundExpression.definitions = definitions;
105
+ for (const name in definitions) {
106
+ registry[name] = CompoundExpression;
107
+ }
108
+ }
109
+ }
110
+
111
+ function stringifySignature(signature) {
112
+ if (Array.isArray(signature)) {
113
+ return `(${signature.map(toString).join(', ')})`;
114
+ }
115
+ return `(${toString(signature.type)}...)`;
116
+ }
117
+
118
+ module.exports = CompoundExpression;
@@ -0,0 +1,82 @@
1
+ const { toString, array, ValueType, StringType, NumberType, BooleanType, checkSubtype } = require('../types');
2
+
3
+ const { typeOf } = require('../values');
4
+ const RuntimeError = require('../runtime_error');
5
+
6
+ const types = {
7
+ string: StringType,
8
+ number: NumberType,
9
+ boolean: BooleanType
10
+ };
11
+
12
+ class ArrayAssertion {
13
+ constructor(type, input) {
14
+ this.type = type;
15
+ this.input = input;
16
+ }
17
+
18
+ static parse(args, context) {
19
+ if (args.length < 2 || args.length > 4)
20
+ return context.error(`Expected 1, 2, or 3 arguments, but found ${args.length - 1} instead.`);
21
+
22
+ let itemType;
23
+ let N;
24
+ if (args.length > 2) {
25
+ const type = args[1];
26
+ if (typeof type !== 'string' || !(type in types))
27
+ return context.error('The item type argument of "array" must be one of string, number, boolean', 1);
28
+ itemType = types[type];
29
+ } else {
30
+ itemType = ValueType;
31
+ }
32
+
33
+ if (args.length > 3) {
34
+ if (typeof args[2] !== 'number' || args[2] < 0 || args[2] !== Math.floor(args[2])) {
35
+ return context.error('The length argument to "array" must be a positive integer literal', 2);
36
+ }
37
+ N = args[2];
38
+ }
39
+
40
+ const type = array(itemType, N);
41
+
42
+ const input = context.parse(args[args.length - 1], args.length - 1, ValueType);
43
+ if (!input) return null;
44
+
45
+ return new ArrayAssertion(type, input);
46
+ }
47
+
48
+ evaluate(ctx) {
49
+ const value = this.input.evaluate(ctx);
50
+ const error = checkSubtype(this.type, typeOf(value));
51
+ if (error) {
52
+ throw new RuntimeError(
53
+ `Expected value to be of type ${toString(this.type)}, but found ${toString(typeOf(value))} instead.`
54
+ );
55
+ }
56
+ return value;
57
+ }
58
+
59
+ eachChild(fn) {
60
+ fn(this.input);
61
+ }
62
+
63
+ possibleOutputs() {
64
+ return this.input.possibleOutputs();
65
+ }
66
+
67
+ serialize() {
68
+ const serialized = ['array'];
69
+ const itemType = this.type.itemType;
70
+ if (itemType.kind === 'string' || itemType.kind === 'number' || itemType.kind === 'boolean') {
71
+ serialized.push(itemType.kind);
72
+ const N = this.type.N;
73
+ if (typeof N === 'number') {
74
+ serialized.push(N);
75
+ }
76
+ }
77
+ serialized.push(this.input.serialize());
78
+ return serialized;
79
+ }
80
+ }
81
+
82
+ module.exports = ArrayAssertion;
@@ -0,0 +1,69 @@
1
+ const assert = require('assert');
2
+
3
+ const { ObjectType, ValueType, StringType, NumberType, BooleanType, checkSubtype, toString } = require('../types');
4
+ const RuntimeError = require('../runtime_error');
5
+ const { typeOf } = require('../values');
6
+
7
+ const types = {
8
+ string: StringType,
9
+ number: NumberType,
10
+ boolean: BooleanType,
11
+ object: ObjectType
12
+ };
13
+
14
+ class Assertion {
15
+ constructor(type, args) {
16
+ this.type = type;
17
+ this.args = args;
18
+ }
19
+
20
+ static parse(args, context) {
21
+ if (args.length < 2) return context.error('Expected at least one argument.');
22
+
23
+ const name = args[0];
24
+ assert(types[name], name);
25
+
26
+ const type = types[name];
27
+
28
+ const parsed = [];
29
+ for (let i = 1; i < args.length; i++) {
30
+ const input = context.parse(args[i], i, ValueType);
31
+ if (!input) return null;
32
+ parsed.push(input);
33
+ }
34
+
35
+ return new Assertion(type, parsed);
36
+ }
37
+
38
+ evaluate(ctx) {
39
+ for (let i = 0; i < this.args.length; i++) {
40
+ const value = this.args[i].evaluate(ctx);
41
+ const error = checkSubtype(this.type, typeOf(value));
42
+ if (!error) {
43
+ return value;
44
+ }
45
+ if (i === this.args.length - 1) {
46
+ throw new RuntimeError(
47
+ `Expected value to be of type ${toString(this.type)}, but found ${toString(typeOf(value))} instead.`
48
+ );
49
+ }
50
+ }
51
+
52
+ assert(false);
53
+ return null;
54
+ }
55
+
56
+ eachChild(fn) {
57
+ this.args.forEach(fn);
58
+ }
59
+
60
+ possibleOutputs() {
61
+ return [].concat(...this.args.map(arg => arg.possibleOutputs()));
62
+ }
63
+
64
+ serialize() {
65
+ return [this.type.kind].concat(this.args.map(arg => arg.serialize()));
66
+ }
67
+ }
68
+
69
+ module.exports = Assertion;
@@ -0,0 +1,57 @@
1
+ const { array, ValueType, NumberType } = require('../types');
2
+
3
+ const RuntimeError = require('../runtime_error');
4
+
5
+ class At {
6
+ constructor(type, index, input) {
7
+ this.type = type;
8
+ this.index = index;
9
+ this.input = input;
10
+ }
11
+
12
+ static parse(args, context) {
13
+ if (args.length !== 3) return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);
14
+
15
+ const index = context.parse(args[1], 1, NumberType);
16
+ const input = context.parse(args[2], 2, array(context.expectedType || ValueType));
17
+
18
+ if (!index || !input) return null;
19
+
20
+ const t = input.type;
21
+ return new At(t.itemType, index, input);
22
+ }
23
+
24
+ evaluate(ctx) {
25
+ const index = this.index.evaluate(ctx);
26
+ const array = this.input.evaluate(ctx);
27
+
28
+ if (index < 0) {
29
+ throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);
30
+ }
31
+
32
+ if (index >= array.length) {
33
+ throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);
34
+ }
35
+
36
+ if (index !== Math.floor(index)) {
37
+ throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);
38
+ }
39
+
40
+ return array[index];
41
+ }
42
+
43
+ eachChild(fn) {
44
+ fn(this.index);
45
+ fn(this.input);
46
+ }
47
+
48
+ possibleOutputs() {
49
+ return [undefined];
50
+ }
51
+
52
+ serialize() {
53
+ return ['at', this.index.serialize(), this.input.serialize()];
54
+ }
55
+ }
56
+
57
+ module.exports = At;