@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,6 @@
1
+ const { createLayout } = require('../util/struct_array');
2
+
3
+ module.exports = createLayout([
4
+ { name: 'a_pos', type: 'Int16', components: 2 },
5
+ { name: 'a_texture_pos', type: 'Int16', components: 2 }
6
+ ]);
@@ -0,0 +1,63 @@
1
+ const warn = require('../util/warn');
2
+
3
+ const { register } = require('../util/web_worker_transfer');
4
+
5
+ class SegmentVector {
6
+ constructor(segments = []) {
7
+ this.segments = segments;
8
+ }
9
+
10
+ prepareSegment(numVertices, layoutVertexArray, indexArray) {
11
+ let segment = this.segments[this.segments.length - 1];
12
+ if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH)
13
+ warn.once(
14
+ `Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`
15
+ );
16
+ if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
17
+ segment = {
18
+ vertexOffset: layoutVertexArray.length,
19
+ primitiveOffset: indexArray.length,
20
+ vertexLength: 0,
21
+ primitiveLength: 0
22
+ };
23
+ this.segments.push(segment);
24
+ }
25
+ return segment;
26
+ }
27
+
28
+ get() {
29
+ return this.segments;
30
+ }
31
+
32
+ destroy() {
33
+ for (const segment of this.segments) {
34
+ for (const k in segment.vaos) {
35
+ segment.vaos[k].destroy();
36
+ }
37
+ }
38
+ }
39
+
40
+ static simpleSegment(vertexOffset, primitiveOffset, vertexLength, primitiveLength) {
41
+ return new SegmentVector([
42
+ {
43
+ vertexOffset: vertexOffset,
44
+ primitiveOffset: primitiveOffset,
45
+ vertexLength: vertexLength,
46
+ primitiveLength: primitiveLength,
47
+ vaos: {}
48
+ }
49
+ ]);
50
+ }
51
+ }
52
+
53
+ /*
54
+ * The maximum size of a vertex array. This limit is imposed by WebGL's 16 bit
55
+ * addressing of vertex buffers.
56
+ * @private
57
+ * @readonly
58
+ */
59
+ SegmentVector.MAX_VERTEX_ARRAY_LENGTH = 2 ** 16 - 1;
60
+
61
+ register('SegmentVector', SegmentVector);
62
+
63
+ module.exports = SegmentVector;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * A coordinate is a column, row, zoom combination, often used
3
+ * as the data component of a tile.
4
+ *
5
+ * @param {number} column
6
+ * @param {number} row
7
+ * @param {number} zoom
8
+ * @private
9
+ */
10
+ class Coordinate {
11
+ constructor(column, row, zoom) {
12
+ this.column = column;
13
+ this.row = row;
14
+ this.zoom = zoom;
15
+ }
16
+
17
+ /**
18
+ * Create a clone of this coordinate that can be mutated without
19
+ * changing the original coordinate
20
+ *
21
+ * @returns {Coordinate} clone
22
+ * @private
23
+ * var coord = new Coordinate(0, 0, 0);
24
+ * var c2 = coord.clone();
25
+ * // since coord is cloned, modifying a property of c2 does
26
+ * // not modify it.
27
+ * c2.zoom = 2;
28
+ */
29
+ clone() {
30
+ return new Coordinate(this.column, this.row, this.zoom);
31
+ }
32
+
33
+ /**
34
+ * Zoom this coordinate to a given zoom level. This returns a new
35
+ * coordinate object, not mutating the old one.
36
+ *
37
+ * @param {number} zoom
38
+ * @returns {Coordinate} zoomed coordinate
39
+ * @private
40
+ * @example
41
+ * var coord = new Coordinate(0, 0, 0);
42
+ * var c2 = coord.zoomTo(1);
43
+ * c2 // equals new Coordinate(0, 0, 1);
44
+ */
45
+ zoomTo(zoom) {
46
+ return this.clone()._zoomTo(zoom);
47
+ }
48
+
49
+ /**
50
+ * Subtract the column and row values of this coordinate from those
51
+ * of another coordinate. The other coordinat will be zoomed to the
52
+ * same level as `this` before the subtraction occurs
53
+ *
54
+ * @param {Coordinate} c other coordinate
55
+ * @returns {Coordinate} result
56
+ * @private
57
+ */
58
+ sub(c) {
59
+ return this.clone()._sub(c);
60
+ }
61
+
62
+ _zoomTo(zoom) {
63
+ const scale = 2 ** (zoom - this.zoom);
64
+ this.column *= scale;
65
+ this.row *= scale;
66
+ this.zoom = zoom;
67
+ return this;
68
+ }
69
+
70
+ _sub(c) {
71
+ c = c.zoomTo(this.zoom);
72
+ this.column -= c.column;
73
+ this.row -= c.row;
74
+ return this;
75
+ }
76
+ }
77
+
78
+ module.exports = Coordinate;
@@ -0,0 +1,129 @@
1
+ const { wrap } = require('../util/util');
2
+
3
+ /**
4
+ * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
5
+ *
6
+ * Mapbox GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.
7
+ *
8
+ * Note that any Mapbox GL method that accepts a `LngLat` object as an argument or option
9
+ * can also accept an `Array` of two numbers and will perform an implicit conversion.
10
+ * This flexible type is documented as {@link LngLatLike}.
11
+ *
12
+ * @param {number} lng Longitude, measured in degrees.
13
+ * @param {number} lat Latitude, measured in degrees.
14
+ * @example
15
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
16
+ * @see [Get coordinates of the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/mouse-position/)
17
+ * @see [Display a popup](https://www.mapbox.com/mapbox-gl-js/example/popup/)
18
+ * @see [Highlight features within a bounding box](https://www.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)
19
+ * @see [Create a timeline animation](https://www.mapbox.com/mapbox-gl-js/example/timeline-animation/)
20
+ */
21
+ class LngLat {
22
+ constructor(lng, lat) {
23
+ if (isNaN(lng) || isNaN(lat)) {
24
+ throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
25
+ }
26
+ this.lng = +lng;
27
+ this.lat = +lat;
28
+ if (this.lat > 90 || this.lat < -90) {
29
+ throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
35
+ *
36
+ * @returns {LngLat} The wrapped `LngLat` object.
37
+ * @example
38
+ * var ll = new mapboxgl.LngLat(286.0251, 40.7736);
39
+ * var wrapped = ll.wrap();
40
+ * wrapped.lng; // = -73.9749
41
+ */
42
+ wrap() {
43
+ return new LngLat(wrap(this.lng, -180, 180), this.lat);
44
+ }
45
+
46
+ /**
47
+ * Returns the coordinates represented as an array of two numbers.
48
+ *
49
+ * @returns {Array<number>} The coordinates represeted as an array of longitude and latitude.
50
+ * @example
51
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
52
+ * ll.toArray(); // = [-73.9749, 40.7736]
53
+ */
54
+ toArray() {
55
+ return [this.lng, this.lat];
56
+ }
57
+
58
+ /**
59
+ * Returns the coordinates represent as a string.
60
+ *
61
+ * @returns {string} The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
62
+ * @example
63
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
64
+ * ll.toString(); // = "LngLat(-73.9749, 40.7736)"
65
+ */
66
+ toString() {
67
+ return `LngLat(${this.lng}, ${this.lat})`;
68
+ }
69
+
70
+ /**
71
+ * Returns a `LngLatBounds` from the coordinates extended by a given `radius`.
72
+ *
73
+ * @param {number} radius Distance in meters from the coordinates to extend the bounds.
74
+ * @returns {LngLatBounds} A new `LngLatBounds` object representing the coordinates extended by the `radius`.
75
+ * @example
76
+ * var ll = new mapboxgl.LngLat(-73.9749, 40.7736);
77
+ * ll.toBounds(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
78
+ */
79
+ toBounds(radius) {
80
+ const earthCircumferenceInMetersAtEquator = 40075017;
81
+ const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
82
+ const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
83
+ const LngLatBounds = require('./lng_lat_bounds');
84
+
85
+ return new LngLatBounds(
86
+ new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
87
+ new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy)
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Converts an array of two numbers to a `LngLat` object.
93
+ *
94
+ * If a `LngLat` object is passed in, the function returns it unchanged.
95
+ *
96
+ * @param {LngLatLike} input An array of two numbers to convert, or a `LngLat` object to return.
97
+ * @returns {LngLat} A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
98
+ * @example
99
+ * var arr = [-73.9749, 40.7736];
100
+ * var ll = mapboxgl.LngLat.convert(arr);
101
+ * ll; // = LngLat {lng: -73.9749, lat: 40.7736}
102
+ */
103
+ static convert(input) {
104
+ if (input instanceof LngLat) {
105
+ return input;
106
+ }
107
+ if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
108
+ return new LngLat(Number(input[0]), Number(input[1]));
109
+ }
110
+ if (!Array.isArray(input) && typeof input === 'object' && input !== null) {
111
+ return new LngLat(Number(input.lng), Number(input.lat));
112
+ }
113
+ throw new Error(
114
+ '`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]'
115
+ );
116
+ }
117
+ }
118
+
119
+ /**
120
+ * A {@link LngLat} object, an array of two numbers representing longitude and latitude,
121
+ * or an object with `lng` and `lat` properties.
122
+ *
123
+ * @typedef {LngLat | {lng: number, lat: number} | [number, number]} LngLatLike
124
+ * @example
125
+ * var v1 = new mapboxgl.LngLat(-122.420679, 37.772537);
126
+ * var v2 = [-122.420679, 37.772537];
127
+ */
128
+
129
+ module.exports = LngLat;
@@ -0,0 +1,253 @@
1
+ const LngLat = require('./lng_lat');
2
+
3
+ /**
4
+ * A `LngLatBounds` object represents a geographical bounding box,
5
+ * defined by its southwest and northeast points in longitude and latitude.
6
+ *
7
+ * If no arguments are provided to the constructor, a `null` bounding box is created.
8
+ *
9
+ * Note that any Mapbox GL method that accepts a `LngLatBounds` object as an argument or option
10
+ * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion.
11
+ * This flexible type is documented as {@link LngLatBoundsLike}.
12
+ *
13
+ * @param {LngLatLike} [sw] The southwest corner of the bounding box.
14
+ * @param {LngLatLike} [ne] The northeast corner of the bounding box.
15
+ * @example
16
+ * var sw = new mapboxgl.LngLat(-73.9876, 40.7661);
17
+ * var ne = new mapboxgl.LngLat(-73.9397, 40.8002);
18
+ * var llb = new mapboxgl.LngLatBounds(sw, ne);
19
+ */
20
+ class LngLatBounds {
21
+ // This constructor is too flexible to type. It should not be so flexible.
22
+ constructor(sw, ne) {
23
+ if (!sw) {
24
+ return;
25
+ }
26
+ if (ne) {
27
+ this.setSouthWest(sw).setNorthEast(ne);
28
+ } else if (sw.length === 4) {
29
+ this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
30
+ } else {
31
+ this.setSouthWest(sw[0]).setNorthEast(sw[1]);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Set the northeast corner of the bounding box
37
+ *
38
+ * @param {LngLatLike} ne
39
+ * @returns {LngLatBounds} `this`
40
+ */
41
+ setNorthEast(ne) {
42
+ this._ne = ne instanceof LngLat ? new LngLat(ne.lng, ne.lat) : LngLat.convert(ne);
43
+ return this;
44
+ }
45
+
46
+ /**
47
+ * Set the southwest corner of the bounding box
48
+ *
49
+ * @param {LngLatLike} sw
50
+ * @returns {LngLatBounds} `this`
51
+ */
52
+ setSouthWest(sw) {
53
+ this._sw = sw instanceof LngLat ? new LngLat(sw.lng, sw.lat) : LngLat.convert(sw);
54
+ return this;
55
+ }
56
+
57
+ /**
58
+ * Extend the bounds to include a given LngLat or LngLatBounds.
59
+ *
60
+ * @param {LngLat|LngLatBounds} obj object to extend to
61
+ * @returns {LngLatBounds} `this`
62
+ */
63
+ extend(obj) {
64
+ const sw = this._sw;
65
+ const ne = this._ne;
66
+ let sw2;
67
+ let ne2;
68
+
69
+ if (obj instanceof LngLat) {
70
+ sw2 = obj;
71
+ ne2 = obj;
72
+ } else if (obj instanceof LngLatBounds) {
73
+ sw2 = obj._sw;
74
+ ne2 = obj._ne;
75
+
76
+ if (!sw2 || !ne2) return this;
77
+ } else {
78
+ if (Array.isArray(obj)) {
79
+ if (obj.every(Array.isArray)) {
80
+ return this.extend(LngLatBounds.convert(obj));
81
+ }
82
+ return this.extend(LngLat.convert(obj));
83
+ }
84
+ return this;
85
+ }
86
+
87
+ if (!sw && !ne) {
88
+ this._sw = new LngLat(sw2.lng, sw2.lat);
89
+ this._ne = new LngLat(ne2.lng, ne2.lat);
90
+ } else {
91
+ sw.lng = Math.min(sw2.lng, sw.lng);
92
+ sw.lat = Math.min(sw2.lat, sw.lat);
93
+ ne.lng = Math.max(ne2.lng, ne.lng);
94
+ ne.lat = Math.max(ne2.lat, ne.lat);
95
+ }
96
+
97
+ return this;
98
+ }
99
+
100
+ /**
101
+ * Returns the geographical coordinate equidistant from the bounding box's corners.
102
+ *
103
+ * @returns {LngLat} The bounding box's center.
104
+ * @example
105
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
106
+ * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
107
+ */
108
+ getCenter() {
109
+ return new LngLat((this._sw.lng + this._ne.lng) / 2, (this._sw.lat + this._ne.lat) / 2);
110
+ }
111
+
112
+ /**
113
+ * Returns the southwest corner of the bounding box.
114
+ *
115
+ * @returns {LngLat} The southwest corner of the bounding box.
116
+ */
117
+ getSouthWest() {
118
+ return this._sw;
119
+ }
120
+
121
+ /**
122
+ * Returns the northeast corner of the bounding box.
123
+ *
124
+ * @returns {LngLat} The northeast corner of the bounding box.
125
+ */
126
+ getNorthEast() {
127
+ return this._ne;
128
+ }
129
+
130
+ /**
131
+ * Returns the northwest corner of the bounding box.
132
+ *
133
+ * @returns {LngLat} The northwest corner of the bounding box.
134
+ */
135
+ getNorthWest() {
136
+ return new LngLat(this.getWest(), this.getNorth());
137
+ }
138
+
139
+ /**
140
+ * Returns the southeast corner of the bounding box.
141
+ *
142
+ * @returns {LngLat} The southeast corner of the bounding box.
143
+ */
144
+ getSouthEast() {
145
+ return new LngLat(this.getEast(), this.getSouth());
146
+ }
147
+
148
+ /**
149
+ * Returns the west edge of the bounding box.
150
+ *
151
+ * @returns {number} The west edge of the bounding box.
152
+ */
153
+ getWest() {
154
+ return this._sw.lng;
155
+ }
156
+
157
+ /**
158
+ * Returns the south edge of the bounding box.
159
+ *
160
+ * @returns {number} The south edge of the bounding box.
161
+ */
162
+ getSouth() {
163
+ return this._sw.lat;
164
+ }
165
+
166
+ /**
167
+ * Returns the east edge of the bounding box.
168
+ *
169
+ * @returns {number} The east edge of the bounding box.
170
+ */
171
+ getEast() {
172
+ return this._ne.lng;
173
+ }
174
+
175
+ /**
176
+ * Returns the north edge of the bounding box.
177
+ *
178
+ * @returns {number} The north edge of the bounding box.
179
+ */
180
+ getNorth() {
181
+ return this._ne.lat;
182
+ }
183
+
184
+ /**
185
+ * Returns the bounding box represented as an array.
186
+ *
187
+ * @returns {Array<Array<number>>} The bounding box represented as an array, consisting of the
188
+ * southwest and northeast coordinates of the bounding represented as arrays of numbers.
189
+ * @example
190
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
191
+ * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
192
+ */
193
+ toArray() {
194
+ return [this._sw.toArray(), this._ne.toArray()];
195
+ }
196
+
197
+ /**
198
+ * Return the bounding box represented as a string.
199
+ *
200
+ * @returns {string} The bounding box represents as a string of the format
201
+ * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
202
+ * @example
203
+ * var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
204
+ * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
205
+ */
206
+ toString() {
207
+ return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`;
208
+ }
209
+
210
+ /**
211
+ * Check if the bounding box is an empty/`null`-type box.
212
+ *
213
+ * @returns {boolean} True if bounds have been defined, otherwise false.
214
+ */
215
+ isEmpty() {
216
+ return !(this._sw && this._ne);
217
+ }
218
+
219
+ /**
220
+ * Converts an array to a `LngLatBounds` object.
221
+ *
222
+ * If a `LngLatBounds` object is passed in, the function returns it unchanged.
223
+ *
224
+ * Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.
225
+ *
226
+ * @param {LngLatBoundsLike} input An array of two coordinates to convert, or a `LngLatBounds` object to return.
227
+ * @returns {LngLatBounds} A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
228
+ * @example
229
+ * var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
230
+ * var llb = mapboxgl.LngLatBounds.convert(arr);
231
+ * llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
232
+ */
233
+ static convert(input) {
234
+ if (!input || input instanceof LngLatBounds) return input;
235
+ return new LngLatBounds(input);
236
+ }
237
+ }
238
+
239
+ /**
240
+ * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in [sw, ne] order,
241
+ * or an array of numbers in [west, south, east, north] order.
242
+ *
243
+ * @typedef {LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]} LngLatBoundsLike
244
+ * @example
245
+ * var v1 = new mapboxgl.LngLatBounds(
246
+ * new mapboxgl.LngLat(-73.9876, 40.7661),
247
+ * new mapboxgl.LngLat(-73.9397, 40.8002)
248
+ * );
249
+ * var v2 = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002])
250
+ * var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
251
+ */
252
+
253
+ module.exports = LngLatBounds;