@mapgis/mapbox-gl 16.0.0 → 16.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/dist/mapbox-gl.js +4 -4
  2. package/dist/mapbox-gl.js.map +1 -1
  3. package/package.json +4 -5
  4. package/.flowconfig +0 -61
  5. package/LICENSE.txt +0 -84
  6. package/README.md +0 -34
  7. package/build/banner.js +0 -4
  8. package/build/check-bundle-size.js +0 -140
  9. package/build/generate-access-token-script.js +0 -11
  10. package/build/generate-flow-typed-style-spec.js +0 -188
  11. package/build/generate-release-list.js +0 -21
  12. package/build/generate-struct-arrays.js +0 -237
  13. package/build/generate-style-code.js +0 -159
  14. package/build/mapbox-gl.js.flow +0 -3
  15. package/build/print-release-url.js +0 -6
  16. package/build/rollup_plugin_minify_style_spec.js +0 -20
  17. package/build/rollup_plugins.js +0 -80
  18. package/build/run-node +0 -3
  19. package/build/run-tap +0 -8
  20. package/build/test/build-tape.js +0 -19
  21. package/dist/mapbox-gl-csp-worker.js +0 -2
  22. package/dist/mapbox-gl-csp-worker.js.map +0 -1
  23. package/dist/mapbox-gl-csp.js +0 -2
  24. package/dist/mapbox-gl-csp.js.map +0 -1
  25. package/dist/mapbox-gl-dev.js +0 -68798
  26. package/dist/mapbox-gl-unminified.js +0 -45076
  27. package/dist/mapbox-gl-unminified.js.map +0 -1
  28. package/flow-typed/gl.js +0 -5
  29. package/flow-typed/jsdom.js +0 -18
  30. package/flow-typed/mapbox-gl-supported.js +0 -9
  31. package/flow-typed/mapbox-unitbezier.js +0 -14
  32. package/flow-typed/offscreen-canvas.js +0 -9
  33. package/flow-typed/pbf.js +0 -25
  34. package/flow-typed/point-geometry.js +0 -44
  35. package/flow-typed/potpack.js +0 -12
  36. package/flow-typed/sinon.js +0 -28
  37. package/flow-typed/vector-tile.js +0 -41
  38. package/src/css/mapbox-gl.css +0 -798
  39. package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
  40. package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
  41. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
  42. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
  43. package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
  44. package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
  45. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
  46. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
  47. package/src/data/array_types.js +0 -1095
  48. package/src/data/bucket/circle_attributes.js +0 -9
  49. package/src/data/bucket/circle_bucket.js +0 -204
  50. package/src/data/bucket/fill_attributes.js +0 -9
  51. package/src/data/bucket/fill_bucket.js +0 -233
  52. package/src/data/bucket/fill_extrusion_attributes.js +0 -10
  53. package/src/data/bucket/fill_extrusion_bucket.js +0 -289
  54. package/src/data/bucket/heatmap_bucket.js +0 -17
  55. package/src/data/bucket/line_attributes.js +0 -10
  56. package/src/data/bucket/line_bucket.js +0 -556
  57. package/src/data/bucket/pattern_attributes.js +0 -10
  58. package/src/data/bucket/pattern_bucket_features.js +0 -60
  59. package/src/data/bucket/symbol_attributes.js +0 -117
  60. package/src/data/bucket/symbol_bucket.js +0 -972
  61. package/src/data/bucket.js +0 -123
  62. package/src/data/dem_data.js +0 -125
  63. package/src/data/extent.js +0 -18
  64. package/src/data/feature_index.js +0 -321
  65. package/src/data/feature_position_map.js +0 -125
  66. package/src/data/index_array_type.js +0 -16
  67. package/src/data/load_geometry.js +0 -48
  68. package/src/data/pos_attributes.js +0 -6
  69. package/src/data/program_configuration.js +0 -687
  70. package/src/data/raster_bounds_attributes.js +0 -7
  71. package/src/data/segment.js +0 -76
  72. package/src/geo/edge_insets.js +0 -102
  73. package/src/geo/lng_lat.js +0 -165
  74. package/src/geo/lng_lat_bounds.js +0 -267
  75. package/src/geo/mercator_coordinate.js +0 -153
  76. package/src/geo/transform.js +0 -864
  77. package/src/gl/color_mode.js +0 -34
  78. package/src/gl/context.js +0 -298
  79. package/src/gl/cull_face_mode.js +0 -26
  80. package/src/gl/depth_mode.js +0 -29
  81. package/src/gl/framebuffer.js +0 -44
  82. package/src/gl/index_buffer.js +0 -55
  83. package/src/gl/stencil_mode.js +0 -30
  84. package/src/gl/types.js +0 -84
  85. package/src/gl/value.js +0 -520
  86. package/src/gl/vertex_buffer.js +0 -119
  87. package/src/index.js +0 -201
  88. package/src/render/draw_background.js +0 -57
  89. package/src/render/draw_circle.js +0 -113
  90. package/src/render/draw_collision_debug.js +0 -49
  91. package/src/render/draw_custom.js +0 -49
  92. package/src/render/draw_debug.js +0 -127
  93. package/src/render/draw_fill.js +0 -126
  94. package/src/render/draw_fill_extrusion.js +0 -96
  95. package/src/render/draw_heatmap.js +0 -140
  96. package/src/render/draw_hillshade.js +0 -108
  97. package/src/render/draw_line.js +0 -98
  98. package/src/render/draw_raster.js +0 -125
  99. package/src/render/draw_symbol.js +0 -394
  100. package/src/render/glyph_atlas.js +0 -71
  101. package/src/render/glyph_manager.js +0 -182
  102. package/src/render/image_atlas.js +0 -149
  103. package/src/render/image_manager.js +0 -306
  104. package/src/render/line_atlas.js +0 -210
  105. package/src/render/painter.js +0 -653
  106. package/src/render/program/background_program.js +0 -103
  107. package/src/render/program/circle_program.js +0 -69
  108. package/src/render/program/clipping_mask_program.js +0 -20
  109. package/src/render/program/collision_program.js +0 -49
  110. package/src/render/program/debug_program.js +0 -35
  111. package/src/render/program/fill_extrusion_program.js +0 -122
  112. package/src/render/program/fill_program.js +0 -126
  113. package/src/render/program/heatmap_program.js +0 -83
  114. package/src/render/program/hillshade_program.js +0 -122
  115. package/src/render/program/line_program.js +0 -207
  116. package/src/render/program/pattern.js +0 -102
  117. package/src/render/program/program_uniforms.js +0 -42
  118. package/src/render/program/raster_program.js +0 -92
  119. package/src/render/program/symbol_program.js +0 -224
  120. package/src/render/program.js +0 -168
  121. package/src/render/texture.js +0 -122
  122. package/src/render/uniform_binding.js +0 -147
  123. package/src/render/vertex_array_object.js +0 -163
  124. package/src/shaders/README.md +0 -42
  125. package/src/shaders/_prelude.fragment.glsl +0 -17
  126. package/src/shaders/_prelude.vertex.glsl +0 -73
  127. package/src/shaders/background.fragment.glsl +0 -10
  128. package/src/shaders/background.vertex.glsl +0 -7
  129. package/src/shaders/background_pattern.fragment.glsl +0 -28
  130. package/src/shaders/background_pattern.vertex.glsl +0 -20
  131. package/src/shaders/circle.fragment.glsl +0 -39
  132. package/src/shaders/circle.vertex.glsl +0 -64
  133. package/src/shaders/clipping_mask.fragment.glsl +0 -3
  134. package/src/shaders/clipping_mask.vertex.glsl +0 -7
  135. package/src/shaders/collision_box.fragment.glsl +0 -21
  136. package/src/shaders/collision_box.vertex.glsl +0 -27
  137. package/src/shaders/collision_circle.fragment.glsl +0 -34
  138. package/src/shaders/collision_circle.vertex.glsl +0 -36
  139. package/src/shaders/debug.fragment.glsl +0 -9
  140. package/src/shaders/debug.vertex.glsl +0 -12
  141. package/src/shaders/encode_attribute.js +0 -17
  142. package/src/shaders/fill.fragment.glsl +0 -13
  143. package/src/shaders/fill.vertex.glsl +0 -13
  144. package/src/shaders/fill_extrusion.fragment.glsl +0 -9
  145. package/src/shaders/fill_extrusion.vertex.glsl +0 -66
  146. package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
  147. package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
  148. package/src/shaders/fill_outline.fragment.glsl +0 -17
  149. package/src/shaders/fill_outline.vertex.glsl +0 -17
  150. package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
  151. package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
  152. package/src/shaders/fill_pattern.fragment.glsl +0 -36
  153. package/src/shaders/fill_pattern.vertex.glsl +0 -39
  154. package/src/shaders/heatmap.fragment.glsl +0 -22
  155. package/src/shaders/heatmap.vertex.glsl +0 -54
  156. package/src/shaders/heatmap_texture.fragment.glsl +0 -14
  157. package/src/shaders/heatmap_texture.vertex.glsl +0 -11
  158. package/src/shaders/hillshade.fragment.glsl +0 -52
  159. package/src/shaders/hillshade.vertex.glsl +0 -11
  160. package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
  161. package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
  162. package/src/shaders/index.js +0 -20
  163. package/src/shaders/line.fragment.glsl +0 -30
  164. package/src/shaders/line.vertex.glsl +0 -85
  165. package/src/shaders/line_gradient.fragment.glsl +0 -34
  166. package/src/shaders/line_gradient.vertex.glsl +0 -87
  167. package/src/shaders/line_pattern.fragment.glsl +0 -74
  168. package/src/shaders/line_pattern.vertex.glsl +0 -99
  169. package/src/shaders/line_sdf.fragment.glsl +0 -45
  170. package/src/shaders/line_sdf.vertex.glsl +0 -98
  171. package/src/shaders/raster.fragment.glsl +0 -52
  172. package/src/shaders/raster.vertex.glsl +0 -21
  173. package/src/shaders/shaders.js +0 -180
  174. package/src/shaders/symbol_icon.fragment.glsl +0 -17
  175. package/src/shaders/symbol_icon.vertex.glsl +0 -94
  176. package/src/shaders/symbol_sdf.fragment.glsl +0 -52
  177. package/src/shaders/symbol_sdf.vertex.glsl +0 -115
  178. package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
  179. package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
  180. package/src/source/canvas_source.js +0 -238
  181. package/src/source/geojson_helper.js +0 -92
  182. package/src/source/geojson_source.js +0 -374
  183. package/src/source/geojson_worker_source.js +0 -357
  184. package/src/source/geojson_wrapper.js +0 -94
  185. package/src/source/image_source.js +0 -307
  186. package/src/source/load_tilejson.js +0 -39
  187. package/src/source/mbtiles_source.js +0 -115
  188. package/src/source/offline_database.js +0 -61
  189. package/src/source/offline_database_root.js +0 -62
  190. package/src/source/pixels_to_tile_units.js +0 -21
  191. package/src/source/query_features.js +0 -208
  192. package/src/source/raster_dem_tile_source.js +0 -138
  193. package/src/source/raster_dem_tile_worker_source.js +0 -62
  194. package/src/source/raster_tile_offline_source.js +0 -136
  195. package/src/source/raster_tile_source.js +0 -177
  196. package/src/source/rtl_text_plugin.js +0 -138
  197. package/src/source/source.js +0 -137
  198. package/src/source/source_cache.js +0 -957
  199. package/src/source/source_state.js +0 -159
  200. package/src/source/tile.js +0 -465
  201. package/src/source/tile_bounds.js +0 -38
  202. package/src/source/tile_cache.js +0 -212
  203. package/src/source/tile_id.js +0 -402
  204. package/src/source/vector_tile_source.js +0 -192
  205. package/src/source/vector_tile_worker_source.js +0 -216
  206. package/src/source/video_source.js +0 -203
  207. package/src/source/worker.js +0 -237
  208. package/src/source/worker_source.js +0 -106
  209. package/src/source/worker_tile.js +0 -224
  210. package/src/style/create_style_layer.js +0 -36
  211. package/src/style/evaluation_parameters.js +0 -62
  212. package/src/style/light.js +0 -130
  213. package/src/style/load_glyph_range.js +0 -38
  214. package/src/style/load_sprite.js +0 -67
  215. package/src/style/parse_glyph_pbf.js +0 -44
  216. package/src/style/pauseable_placement.js +0 -132
  217. package/src/style/properties.js +0 -753
  218. package/src/style/query_utils.js +0 -43
  219. package/src/style/style.js +0 -1361
  220. package/src/style/style_glyph.js +0 -17
  221. package/src/style/style_image.js +0 -137
  222. package/src/style/style_layer/background_style_layer.js +0 -21
  223. package/src/style/style_layer/background_style_layer_properties.js +0 -40
  224. package/src/style/style_layer/circle_style_layer.js +0 -98
  225. package/src/style/style_layer/circle_style_layer_properties.js +0 -63
  226. package/src/style/style_layer/custom_style_layer.js +0 -223
  227. package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
  228. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
  229. package/src/style/style_layer/fill_style_layer.js +0 -67
  230. package/src/style/style_layer/fill_style_layer_properties.js +0 -55
  231. package/src/style/style_layer/heatmap_style_layer.js +0 -69
  232. package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
  233. package/src/style/style_layer/hillshade_style_layer.js +0 -25
  234. package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
  235. package/src/style/style_layer/layer_properties.js.ejs +0 -69
  236. package/src/style/style_layer/line_style_layer.js +0 -151
  237. package/src/style/style_layer/line_style_layer_properties.js +0 -71
  238. package/src/style/style_layer/raster_style_layer.js +0 -21
  239. package/src/style/style_layer/raster_style_layer_properties.js +0 -50
  240. package/src/style/style_layer/symbol_style_layer.js +0 -190
  241. package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
  242. package/src/style/style_layer/typed_style_layer.js +0 -17
  243. package/src/style/style_layer.js +0 -281
  244. package/src/style/style_layer_index.js +0 -80
  245. package/src/style/validate_style.js +0 -42
  246. package/src/style/zoom_history.js +0 -44
  247. package/src/style-spec/.eslintrc +0 -5
  248. package/src/style-spec/CHANGELOG.md +0 -438
  249. package/src/style-spec/README.md +0 -59
  250. package/src/style-spec/bin/gl-style-composite +0 -9
  251. package/src/style-spec/bin/gl-style-format +0 -22
  252. package/src/style-spec/bin/gl-style-migrate +0 -9
  253. package/src/style-spec/bin/gl-style-validate +0 -50
  254. package/src/style-spec/composite.js +0 -50
  255. package/src/style-spec/declass.js +0 -42
  256. package/src/style-spec/deref.js +0 -52
  257. package/src/style-spec/diff.js +0 -393
  258. package/src/style-spec/dist/.gitkeep +0 -0
  259. package/src/style-spec/empty.js +0 -29
  260. package/src/style-spec/error/parsing_error.js +0 -16
  261. package/src/style-spec/error/validation_error.js +0 -18
  262. package/src/style-spec/expression/compound_expression.js +0 -162
  263. package/src/style-spec/expression/definitions/assertion.js +0 -130
  264. package/src/style-spec/expression/definitions/at.js +0 -70
  265. package/src/style-spec/expression/definitions/case.js +0 -85
  266. package/src/style-spec/expression/definitions/coalesce.js +0 -93
  267. package/src/style-spec/expression/definitions/coercion.js +0 -133
  268. package/src/style-spec/expression/definitions/collator.js +0 -78
  269. package/src/style-spec/expression/definitions/comparison.js +0 -184
  270. package/src/style-spec/expression/definitions/format.js +0 -144
  271. package/src/style-spec/expression/definitions/format_section_override.js +0 -54
  272. package/src/style-spec/expression/definitions/image.js +0 -52
  273. package/src/style-spec/expression/definitions/in.js +0 -92
  274. package/src/style-spec/expression/definitions/index.js +0 -561
  275. package/src/style-spec/expression/definitions/interpolate.js +0 -267
  276. package/src/style-spec/expression/definitions/length.js +0 -61
  277. package/src/style-spec/expression/definitions/let.js +0 -72
  278. package/src/style-spec/expression/definitions/literal.js +0 -77
  279. package/src/style-spec/expression/definitions/match.js +0 -158
  280. package/src/style-spec/expression/definitions/number_format.js +0 -142
  281. package/src/style-spec/expression/definitions/step.js +0 -120
  282. package/src/style-spec/expression/definitions/var.js +0 -46
  283. package/src/style-spec/expression/definitions/within.js +0 -333
  284. package/src/style-spec/expression/evaluation_context.js +0 -59
  285. package/src/style-spec/expression/expression.js +0 -27
  286. package/src/style-spec/expression/index.js +0 -392
  287. package/src/style-spec/expression/is_constant.js +0 -59
  288. package/src/style-spec/expression/parsing_context.js +0 -233
  289. package/src/style-spec/expression/parsing_error.js +0 -13
  290. package/src/style-spec/expression/runtime_error.js +0 -17
  291. package/src/style-spec/expression/scope.js +0 -36
  292. package/src/style-spec/expression/stops.js +0 -39
  293. package/src/style-spec/expression/types/collator.js +0 -61
  294. package/src/style-spec/expression/types/formatted.js +0 -73
  295. package/src/style-spec/expression/types/resolved_image.js +0 -29
  296. package/src/style-spec/expression/types.js +0 -106
  297. package/src/style-spec/expression/values.js +0 -123
  298. package/src/style-spec/feature_filter/README.md +0 -55
  299. package/src/style-spec/feature_filter/convert.js +0 -208
  300. package/src/style-spec/feature_filter/index.js +0 -165
  301. package/src/style-spec/format.js +0 -51
  302. package/src/style-spec/function/convert.js +0 -254
  303. package/src/style-spec/function/index.js +0 -262
  304. package/src/style-spec/group_by_layout.js +0 -75
  305. package/src/style-spec/migrate/expressions.js +0 -39
  306. package/src/style-spec/migrate/v8.js +0 -203
  307. package/src/style-spec/migrate/v9.js +0 -26
  308. package/src/style-spec/migrate.js +0 -36
  309. package/src/style-spec/package.json +0 -41
  310. package/src/style-spec/read_style.js +0 -14
  311. package/src/style-spec/reference/latest.js +0 -3
  312. package/src/style-spec/reference/v8.json +0 -5808
  313. package/src/style-spec/rollup.config.js +0 -45
  314. package/src/style-spec/style-spec.js +0 -122
  315. package/src/style-spec/types.js +0 -438
  316. package/src/style-spec/util/color.js +0 -95
  317. package/src/style-spec/util/color_spaces.js +0 -139
  318. package/src/style-spec/util/deep_equal.js +0 -28
  319. package/src/style-spec/util/extend.js +0 -10
  320. package/src/style-spec/util/get_type.js +0 -17
  321. package/src/style-spec/util/interpolate.js +0 -22
  322. package/src/style-spec/util/properties.js +0 -15
  323. package/src/style-spec/util/ref_properties.js +0 -2
  324. package/src/style-spec/util/result.js +0 -19
  325. package/src/style-spec/util/unbundle_jsonlint.js +0 -24
  326. package/src/style-spec/validate/latest.js +0 -11
  327. package/src/style-spec/validate/validate.js +0 -75
  328. package/src/style-spec/validate/validate_array.js +0 -52
  329. package/src/style-spec/validate/validate_boolean.js +0 -15
  330. package/src/style-spec/validate/validate_color.js +0 -20
  331. package/src/style-spec/validate/validate_constants.js +0 -13
  332. package/src/style-spec/validate/validate_enum.js +0 -21
  333. package/src/style-spec/validate/validate_expression.js +0 -43
  334. package/src/style-spec/validate/validate_filter.js +0 -111
  335. package/src/style-spec/validate/validate_formatted.js +0 -11
  336. package/src/style-spec/validate/validate_function.js +0 -207
  337. package/src/style-spec/validate/validate_glyphs_url.js +0 -21
  338. package/src/style-spec/validate/validate_image.js +0 -11
  339. package/src/style-spec/validate/validate_layer.js +0 -134
  340. package/src/style-spec/validate/validate_layout_property.js +0 -6
  341. package/src/style-spec/validate/validate_light.js +0 -47
  342. package/src/style-spec/validate/validate_number.js +0 -29
  343. package/src/style-spec/validate/validate_object.js +0 -61
  344. package/src/style-spec/validate/validate_paint_property.js +0 -6
  345. package/src/style-spec/validate/validate_property.js +0 -64
  346. package/src/style-spec/validate/validate_source.js +0 -111
  347. package/src/style-spec/validate/validate_string.js +0 -15
  348. package/src/style-spec/validate_mapbox_api_supported.js +0 -171
  349. package/src/style-spec/validate_style.js +0 -39
  350. package/src/style-spec/validate_style.min.js +0 -78
  351. package/src/style-spec/visit.js +0 -77
  352. package/src/symbol/anchor.js +0 -26
  353. package/src/symbol/check_max_angle.js +0 -81
  354. package/src/symbol/clip_line.js +0 -71
  355. package/src/symbol/collision_feature.js +0 -217
  356. package/src/symbol/collision_index.js +0 -372
  357. package/src/symbol/cross_tile_symbol_index.js +0 -301
  358. package/src/symbol/get_anchors.js +0 -167
  359. package/src/symbol/grid_index.js +0 -335
  360. package/src/symbol/mergelines.js +0 -82
  361. package/src/symbol/one_em.js +0 -4
  362. package/src/symbol/opacity_state.js +0 -27
  363. package/src/symbol/placement.js +0 -1062
  364. package/src/symbol/projection.js +0 -450
  365. package/src/symbol/quads.js +0 -334
  366. package/src/symbol/shaping.js +0 -816
  367. package/src/symbol/symbol_layout.js +0 -772
  368. package/src/symbol/symbol_size.js +0 -113
  369. package/src/symbol/transform_text.js +0 -29
  370. package/src/types/callback.js +0 -17
  371. package/src/types/cancelable.js +0 -3
  372. package/src/types/tilejson.js +0 -17
  373. package/src/types/transferable.js +0 -3
  374. package/src/types/window.js +0 -172
  375. package/src/ui/anchor.js +0 -32
  376. package/src/ui/bind_handlers.js +0 -202
  377. package/src/ui/camera.js +0 -1152
  378. package/src/ui/control/attribution_control.js +0 -189
  379. package/src/ui/control/fps_control.js +0 -185
  380. package/src/ui/control/fullscreen_control.js +0 -147
  381. package/src/ui/control/geolocate_control.js +0 -594
  382. package/src/ui/control/logo_control.js +0 -92
  383. package/src/ui/control/navigation_control.js +0 -148
  384. package/src/ui/control/scale_control.js +0 -142
  385. package/src/ui/crs.js +0 -64
  386. package/src/ui/default_locale.js +0 -20
  387. package/src/ui/events.js +0 -806
  388. package/src/ui/handler/box_zoom.js +0 -175
  389. package/src/ui/handler/dblclick_zoom.js +0 -139
  390. package/src/ui/handler/drag_pan.js +0 -416
  391. package/src/ui/handler/drag_rotate.js +0 -378
  392. package/src/ui/handler/keyboard.js +0 -161
  393. package/src/ui/handler/scroll_zoom.js +0 -333
  394. package/src/ui/handler/touch_zoom_rotate.js +0 -293
  395. package/src/ui/hash.js +0 -147
  396. package/src/ui/map.js +0 -2883
  397. package/src/ui/marker.js +0 -607
  398. package/src/ui/offline_map.js +0 -91
  399. package/src/ui/popup.js +0 -530
  400. package/src/util/actor.js +0 -212
  401. package/src/util/ajax.js +0 -371
  402. package/src/util/browser/web_worker.js +0 -10
  403. package/src/util/browser/window.js +0 -5
  404. package/src/util/browser.js +0 -70
  405. package/src/util/classify_rings.js +0 -52
  406. package/src/util/color_ramp.js +0 -28
  407. package/src/util/config.js +0 -30
  408. package/src/util/debug.js +0 -12
  409. package/src/util/dictionary_coder.js +0 -30
  410. package/src/util/dispatcher.js +0 -70
  411. package/src/util/dom.js +0 -144
  412. package/src/util/evented.js +0 -174
  413. package/src/util/find_pole_of_inaccessibility.js +0 -129
  414. package/src/util/global_worker_pool.js +0 -17
  415. package/src/util/image.js +0 -142
  416. package/src/util/intersection_tests.js +0 -208
  417. package/src/util/is_char_in_unicode_block.js +0 -311
  418. package/src/util/mapbox.js +0 -486
  419. package/src/util/offscreen_canvas_supported.js +0 -14
  420. package/src/util/performance.js +0 -112
  421. package/src/util/primitives.js +0 -145
  422. package/src/util/resolve_tokens.js +0 -16
  423. package/src/util/script_detection.js +0 -328
  424. package/src/util/sku_token.js +0 -42
  425. package/src/util/smart_wrap.js +0 -55
  426. package/src/util/struct_array.js +0 -243
  427. package/src/util/struct_array.js.ejs +0 -112
  428. package/src/util/struct_array_layout.js.ejs +0 -98
  429. package/src/util/task_queue.js +0 -68
  430. package/src/util/throttle.js +0 -28
  431. package/src/util/throttled_invoker.js +0 -46
  432. package/src/util/tile_cover.js +0 -101
  433. package/src/util/tile_request_cache.js +0 -172
  434. package/src/util/util.js +0 -504
  435. package/src/util/vectortile_to_geojson.js +0 -54
  436. package/src/util/verticalize_punctuation.js +0 -114
  437. package/src/util/web_worker.js +0 -91
  438. package/src/util/web_worker_transfer.js +0 -266
  439. package/src/util/webp_supported.js +0 -69
  440. package/src/util/window.js +0 -102
  441. package/src/util/worker_pool.js +0 -47
@@ -1,957 +0,0 @@
1
- // @flow
2
-
3
- import {create as createSource} from './source';
4
-
5
- import Tile from './tile';
6
- import {Event, ErrorEvent, Evented} from '../util/evented';
7
- import TileCache from './tile_cache';
8
- import MercatorCoordinate from '../geo/mercator_coordinate';
9
- import {keysDifference, values} from '../util/util';
10
- import EXTENT from '../data/extent';
11
- import Context from '../gl/context';
12
- import Point from '@mapbox/point-geometry';
13
- import browser from '../util/browser';
14
- import {OverscaledTileID} from './tile_id';
15
- import assert from 'assert';
16
- import SourceFeatureState from './source_state';
17
-
18
- import type {Source} from './source';
19
- import type Map from '../ui/map';
20
- import type Style from '../style/style';
21
- import type Dispatcher from '../util/dispatcher';
22
- import type Transform from '../geo/transform';
23
- import type {TileState} from './tile';
24
- import type {Callback} from '../types/callback';
25
- import type {SourceSpecification} from '../style-spec/types';
26
-
27
- /**
28
- * `SourceCache` is responsible for
29
- *
30
- * - creating an instance of `Source`
31
- * - forwarding events from `Source`
32
- * - caching tiles loaded from an instance of `Source`
33
- * - loading the tiles needed to render a given viewport
34
- * - unloading the cached tiles not needed to render a given viewport
35
- *
36
- * @private
37
- */
38
- class SourceCache extends Evented {
39
- id: string;
40
- dispatcher: Dispatcher;
41
- map: Map;
42
- style: Style;
43
-
44
- _source: Source;
45
- _sourceLoaded: boolean;
46
- _sourceErrored: boolean;
47
- _tiles: {[_: string]: Tile};
48
- _prevLng: number | void;
49
- _cache: TileCache;
50
- _timers: {[_: any]: TimeoutID};
51
- _cacheTimers: {[_: any]: TimeoutID};
52
- _maxTileCacheSize: ?number;
53
- _paused: boolean;
54
- _shouldReloadOnResume: boolean;
55
- _coveredTiles: {[_: string]: boolean};
56
- transform: Transform;
57
- _isIdRenderable: (id: string, symbolLayer?: boolean) => boolean;
58
- used: boolean;
59
- _state: SourceFeatureState;
60
- _loadedParentTiles: {[_: string]: ?Tile};
61
-
62
- static maxUnderzooming: number;
63
- static maxOverzooming: number;
64
-
65
- constructor(id: string, options: SourceSpecification, dispatcher: Dispatcher) {
66
- super();
67
- this.id = id;
68
- this.dispatcher = dispatcher;
69
-
70
- this.on('data', (e) => {
71
- // this._sourceLoaded signifies that the TileJSON is loaded if applicable.
72
- // if the source type does not come with a TileJSON, the flag signifies the
73
- // source data has loaded (i.e geojson has been tiled on the worker and is ready)
74
- if (e.dataType === 'source' && e.sourceDataType === 'metadata') this._sourceLoaded = true;
75
-
76
- // for sources with mutable data, this event fires when the underlying data
77
- // to a source is changed. (i.e. GeoJSONSource#setData and ImageSource#serCoordinates)
78
- if (this._sourceLoaded && !this._paused && e.dataType === "source" && e.sourceDataType === 'content') {
79
- this.reload();
80
- if (this.transform) {
81
- this.update(this.transform);
82
- }
83
- }
84
- });
85
-
86
- this.on('error', () => {
87
- this._sourceErrored = true;
88
- });
89
-
90
- this._source = createSource(id, options, dispatcher, this);
91
-
92
- this._tiles = {};
93
- this._cache = new TileCache(0, this._unloadTile.bind(this));
94
- this._timers = {};
95
- this._cacheTimers = {};
96
- this._maxTileCacheSize = null;
97
- this._loadedParentTiles = {};
98
-
99
- this._coveredTiles = {};
100
- this._state = new SourceFeatureState();
101
- }
102
-
103
- onAdd(map: Map) {
104
- this.map = map;
105
- this._maxTileCacheSize = map ? map._maxTileCacheSize : null;
106
- if (this._source && this._source.onAdd) {
107
- this._source.onAdd(map);
108
- }
109
- }
110
-
111
- onRemove(map: Map) {
112
- if (this._source && this._source.onRemove) {
113
- this._source.onRemove(map);
114
- }
115
- }
116
-
117
- /**
118
- * Return true if no tile data is pending, tiles will not change unless
119
- * an additional API call is received.
120
- * @private
121
- */
122
- loaded(): boolean {
123
- if (this._sourceErrored) { return true; }
124
- if (!this._sourceLoaded) { return false; }
125
- if (!this._source.loaded()) { return false; }
126
- for (const t in this._tiles) {
127
- const tile = this._tiles[t];
128
- if (tile.state !== 'loaded' && tile.state !== 'errored')
129
- return false;
130
- }
131
- return true;
132
- }
133
-
134
- getSource(): Source {
135
- return this._source;
136
- }
137
-
138
- pause() {
139
- this._paused = true;
140
- }
141
-
142
- resume() {
143
- if (!this._paused) return;
144
- const shouldReload = this._shouldReloadOnResume;
145
- this._paused = false;
146
- this._shouldReloadOnResume = false;
147
- if (shouldReload) this.reload();
148
- if (this.transform) this.update(this.transform);
149
- }
150
-
151
- _loadTile(tile: Tile, callback: Callback<void>) {
152
- return this._source.loadTile(tile, callback);
153
- }
154
-
155
- _unloadTile(tile: Tile) {
156
- if (this._source.unloadTile)
157
- return this._source.unloadTile(tile, () => {});
158
- }
159
-
160
- _abortTile(tile: Tile) {
161
- if (this._source.abortTile)
162
- return this._source.abortTile(tile, () => {});
163
- }
164
-
165
- serialize() {
166
- return this._source.serialize();
167
- }
168
-
169
- prepare(context: Context) {
170
- if (this._source.prepare) {
171
- this._source.prepare();
172
- }
173
-
174
- this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null);
175
- for (const i in this._tiles) {
176
- const tile = this._tiles[i];
177
- tile.upload(context);
178
- tile.prepare(this.map.style.imageManager);
179
- }
180
- }
181
-
182
- /**
183
- * Return all tile ids ordered with z-order, and cast to numbers
184
- * @private
185
- */
186
- getIds(): Array<string> {
187
- return (values(this._tiles): any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key);
188
- }
189
-
190
- getRenderableIds(symbolLayer?: boolean): Array<string> {
191
- const renderables: Array<Tile> = [];
192
- for (const id in this._tiles) {
193
- if (this._isIdRenderable(id, symbolLayer)) renderables.push(this._tiles[id]);
194
- }
195
- if (symbolLayer) {
196
- return renderables.sort((a_: Tile, b_: Tile) => {
197
- const a = a_.tileID;
198
- const b = b_.tileID;
199
- const rotatedA = (new Point(a.canonical.x, a.canonical.y))._rotate(this.transform.angle);
200
- const rotatedB = (new Point(b.canonical.x, b.canonical.y))._rotate(this.transform.angle);
201
- return a.overscaledZ - b.overscaledZ || rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x;
202
- }).map(tile => tile.tileID.key);
203
- }
204
- return renderables.map(tile => tile.tileID).sort(compareTileId).map(id => id.key);
205
- }
206
-
207
- hasRenderableParent(tileID: OverscaledTileID) {
208
- const parentTile = this.findLoadedParent(tileID, 0);
209
- if (parentTile) {
210
- return this._isIdRenderable(parentTile.tileID.key);
211
- }
212
- return false;
213
- }
214
-
215
- _isIdRenderable(id: string, symbolLayer?: boolean) {
216
- return this._tiles[id] && this._tiles[id].hasData() &&
217
- !this._coveredTiles[id] && (symbolLayer || !this._tiles[id].holdingForFade());
218
- }
219
-
220
- reload() {
221
- if (this._paused) {
222
- this._shouldReloadOnResume = true;
223
- return;
224
- }
225
-
226
- this._cache.reset();
227
-
228
- for (const i in this._tiles) {
229
- if (this._tiles[i].state !== "errored") this._reloadTile(i, 'reloading');
230
- }
231
- }
232
-
233
- _reloadTile(id: string, state: TileState) {
234
- const tile = this._tiles[id];
235
-
236
- // this potentially does not address all underlying
237
- // issues https://github.com/mapbox/mapbox-gl-js/issues/4252
238
- // - hard to tell without repro steps
239
- if (!tile) return;
240
-
241
- // The difference between "loading" tiles and "reloading" or "expired"
242
- // tiles is that "reloading"/"expired" tiles are "renderable".
243
- // Therefore, a "loading" tile cannot become a "reloading" tile without
244
- // first becoming a "loaded" tile.
245
- if (tile.state !== 'loading') {
246
- tile.state = state;
247
- }
248
-
249
- this._loadTile(tile, this._tileLoaded.bind(this, tile, id, state));
250
- }
251
-
252
- _tileLoaded(tile: Tile, id: string, previousState: TileState, err: ?Error) {
253
- if (err) {
254
- tile.state = 'errored';
255
- if ((err: any).status !== 404) this._source.fire(new ErrorEvent(err, {tile}));
256
- // continue to try loading parent/children tiles if a tile doesn't exist (404)
257
- else this.update(this.transform);
258
- return;
259
- }
260
-
261
- tile.timeAdded = browser.now();
262
- if (previousState === 'expired') tile.refreshedUponExpiration = true;
263
- this._setTileReloadTimer(id, tile);
264
- if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile);
265
- this._state.initializeTileState(tile, this.map ? this.map.painter : null);
266
-
267
- this._source.fire(new Event('data', {dataType: 'source', tile, coord: tile.tileID}));
268
- }
269
-
270
- /**
271
- * For raster terrain source, backfill DEM to eliminate visible tile boundaries
272
- * @private
273
- */
274
- _backfillDEM(tile: Tile) {
275
- const renderables = this.getRenderableIds();
276
- for (let i = 0; i < renderables.length; i++) {
277
- const borderId = renderables[i];
278
- if (tile.neighboringTiles && tile.neighboringTiles[borderId]) {
279
- const borderTile = this.getTileByID(borderId);
280
- fillBorder(tile, borderTile);
281
- fillBorder(borderTile, tile);
282
- }
283
- }
284
-
285
- function fillBorder(tile, borderTile) {
286
- tile.needsHillshadePrepare = true;
287
- let dx = borderTile.tileID.canonical.x - tile.tileID.canonical.x;
288
- const dy = borderTile.tileID.canonical.y - tile.tileID.canonical.y;
289
- const dim = Math.pow(2, tile.tileID.canonical.z);
290
- const borderId = borderTile.tileID.key;
291
- if (dx === 0 && dy === 0) return;
292
-
293
- if (Math.abs(dy) > 1) {
294
- return;
295
- }
296
- if (Math.abs(dx) > 1) {
297
- // Adjust the delta coordinate for world wraparound.
298
- if (Math.abs(dx + dim) === 1) {
299
- dx += dim;
300
- } else if (Math.abs(dx - dim) === 1) {
301
- dx -= dim;
302
- }
303
- }
304
- if (!borderTile.dem || !tile.dem) return;
305
- tile.dem.backfillBorder(borderTile.dem, dx, dy);
306
- if (tile.neighboringTiles && tile.neighboringTiles[borderId])
307
- tile.neighboringTiles[borderId].backfilled = true;
308
- }
309
- }
310
- /**
311
- * Get a specific tile by TileID
312
- * @private
313
- */
314
- getTile(tileID: OverscaledTileID): Tile {
315
- return this.getTileByID(tileID.key);
316
- }
317
-
318
- /**
319
- * Get a specific tile by id
320
- * @private
321
- */
322
- getTileByID(id: string): Tile {
323
- return this._tiles[id];
324
- }
325
-
326
- /**
327
- * For a given set of tiles, retain children that are loaded and have a zoom
328
- * between `zoom` (exclusive) and `maxCoveringZoom` (inclusive)
329
- * @private
330
- */
331
- _retainLoadedChildren(
332
- idealTiles: {[_: any]: OverscaledTileID},
333
- zoom: number,
334
- maxCoveringZoom: number,
335
- retain: {[_: any]: OverscaledTileID}
336
- ) {
337
- for (const id in this._tiles) {
338
- let tile = this._tiles[id];
339
-
340
- // only consider renderable tiles up to maxCoveringZoom
341
- if (retain[id] ||
342
- !tile.hasData() ||
343
- tile.tileID.overscaledZ <= zoom ||
344
- tile.tileID.overscaledZ > maxCoveringZoom
345
- ) continue;
346
-
347
- // loop through parents and retain the topmost loaded one if found
348
- let topmostLoadedID = tile.tileID;
349
- while (tile && tile.tileID.overscaledZ > zoom + 1) {
350
- const parentID = tile.tileID.scaledTo(tile.tileID.overscaledZ - 1);
351
-
352
- tile = this._tiles[parentID.key];
353
-
354
- if (tile && tile.hasData()) {
355
- topmostLoadedID = parentID;
356
- }
357
- }
358
-
359
- // loop through ancestors of the topmost loaded child to see if there's one that needed it
360
- let tileID = topmostLoadedID;
361
- while (tileID.overscaledZ > zoom) {
362
- tileID = tileID.scaledTo(tileID.overscaledZ - 1);
363
-
364
- if (idealTiles[tileID.key]) {
365
- // found a parent that needed a loaded child; retain that child
366
- retain[topmostLoadedID.key] = topmostLoadedID;
367
- break;
368
- }
369
- }
370
- }
371
- }
372
-
373
- /**
374
- * Find a loaded parent of the given tile (up to minCoveringZoom)
375
- * @private
376
- */
377
- findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): ?Tile {
378
- if (tileID.key in this._loadedParentTiles) {
379
- const parent = this._loadedParentTiles[tileID.key];
380
- if (parent && parent.tileID.overscaledZ >= minCoveringZoom) {
381
- return parent;
382
- } else {
383
- return null;
384
- }
385
- }
386
- for (let z = tileID.overscaledZ - 1; z >= minCoveringZoom; z--) {
387
- const parentTileID = tileID.scaledTo(z);
388
- const tile = this._getLoadedTile(parentTileID);
389
- if (tile) {
390
- return tile;
391
- }
392
- }
393
- }
394
-
395
- _getLoadedTile(tileID: OverscaledTileID): ?Tile {
396
- const tile = this._tiles[tileID.key];
397
- if (tile && tile.hasData()) {
398
- return tile;
399
- }
400
- // TileCache ignores wrap in lookup.
401
- const cachedTile = this._cache.getByKey(tileID.wrapped().key);
402
- return cachedTile;
403
- }
404
-
405
- /**
406
- * Resizes the tile cache based on the current viewport's size
407
- * or the maxTileCacheSize option passed during map creation
408
- *
409
- * Larger viewports use more tiles and need larger caches. Larger viewports
410
- * are more likely to be found on devices with more memory and on pages where
411
- * the map is more important.
412
- * @private
413
- */
414
- updateCacheSize(transform: Transform) {
415
- const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1;
416
- const heightInTiles = Math.ceil(transform.height / this._source.tileSize) + 1;
417
- const approxTilesInView = widthInTiles * heightInTiles;
418
- const commonZoomRange = 5;
419
-
420
- const viewDependentMaxSize = Math.floor(approxTilesInView * commonZoomRange);
421
- const maxSize = typeof this._maxTileCacheSize === 'number' ? Math.min(this._maxTileCacheSize, viewDependentMaxSize) : viewDependentMaxSize;
422
-
423
- this._cache.setMaxSize(maxSize);
424
- }
425
-
426
- handleWrapJump(lng: number) {
427
- // On top of the regular z/x/y values, TileIDs have a `wrap` value that specify
428
- // which cppy of the world the tile belongs to. For example, at `lng: 10` you
429
- // might render z/x/y/0 while at `lng: 370` you would render z/x/y/1.
430
- //
431
- // When lng values get wrapped (going from `lng: 370` to `long: 10`) you expect
432
- // to see the same thing on the screen (370 degrees and 10 degrees is the same
433
- // place in the world) but all the TileIDs will have different wrap values.
434
- //
435
- // In order to make this transition seamless, we calculate the rounded difference of
436
- // "worlds" between the last frame and the current frame. If the map panned by
437
- // a world, then we can assign all the tiles new TileIDs with updated wrap values.
438
- // For example, assign z/x/y/1 a new id: z/x/y/0. It is the same tile, just rendered
439
- // in a different position.
440
- //
441
- // This enables us to reuse the tiles at more ideal locations and prevent flickering.
442
- const prevLng = this._prevLng === undefined ? lng : this._prevLng;
443
- const lngDifference = lng - prevLng;
444
- const worldDifference = lngDifference / 360;
445
- const wrapDelta = Math.round(worldDifference);
446
- this._prevLng = lng;
447
-
448
- if (wrapDelta) {
449
- const tiles: {[_: string]: Tile} = {};
450
- for (const key in this._tiles) {
451
- const tile = this._tiles[key];
452
- tile.tileID = tile.tileID.unwrapTo(tile.tileID.wrap + wrapDelta);
453
- tiles[tile.tileID.key] = tile;
454
- }
455
- this._tiles = tiles;
456
-
457
- // Reset tile reload timers
458
- for (const id in this._timers) {
459
- clearTimeout(this._timers[id]);
460
- delete this._timers[id];
461
- }
462
- for (const id in this._tiles) {
463
- const tile = this._tiles[id];
464
- this._setTileReloadTimer(id, tile);
465
- }
466
- }
467
- }
468
-
469
- /**
470
- * Removes tiles that are outside the viewport and adds new tiles that
471
- * are inside the viewport.
472
- * @private
473
- */
474
- update(transform: Transform) {
475
- this.transform = transform;
476
- if (!this._sourceLoaded || this._paused) { return; }
477
-
478
- this.updateCacheSize(transform);
479
- this.handleWrapJump(this.transform.center.lng);
480
-
481
- // Covered is a list of retained tiles who's areas are fully covered by other,
482
- // better, retained tiles. They are not drawn separately.
483
- this._coveredTiles = {};
484
-
485
- let idealTileIDs;
486
- if (!this.used) {
487
- idealTileIDs = [];
488
- } else if (this._source.tileID) {
489
- idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID)
490
- .map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y));
491
- } else {
492
- idealTileIDs = transform.coveringTiles({
493
- tileSize: this._source.tileSize,
494
- minzoom: this._source.minzoom,
495
- maxzoom: this._source.maxzoom,
496
- roundZoom: this._source.roundZoom,
497
- reparseOverscaled: this._source.reparseOverscaled
498
- });
499
-
500
- if (this._source.hasTile) {
501
- idealTileIDs = idealTileIDs.filter((coord) => (this._source.hasTile: any)(coord));
502
- }
503
- }
504
-
505
- // Determine the overzooming/underzooming amounts.
506
- const zoom = transform.coveringZoomLevel(this._source);
507
- const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);
508
- const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);
509
-
510
- // Retain is a list of tiles that we shouldn't delete, even if they are not
511
- // the most ideal tile for the current viewport. This may include tiles like
512
- // parent or child tiles that are *already* loaded.
513
- const retain = this._updateRetainedTiles(idealTileIDs, zoom);
514
-
515
- if (isRasterType(this._source.type)) {
516
- const parentsForFading: {[_: string]: OverscaledTileID} = {};
517
- const fadingTiles = {};
518
- const ids = Object.keys(retain);
519
- for (const id of ids) {
520
- const tileID = retain[id];
521
- assert(tileID.key === id);
522
-
523
- const tile = this._tiles[id];
524
- if (!tile || tile.fadeEndTime && tile.fadeEndTime <= browser.now()) continue;
525
-
526
- // if the tile is loaded but still fading in, find parents to cross-fade with it
527
- const parentTile = this.findLoadedParent(tileID, minCoveringZoom);
528
- if (parentTile) {
529
- this._addTile(parentTile.tileID);
530
- parentsForFading[parentTile.tileID.key] = parentTile.tileID;
531
- }
532
-
533
- fadingTiles[id] = tileID;
534
- }
535
-
536
- // for tiles that are still fading in, also find children to cross-fade with
537
- this._retainLoadedChildren(fadingTiles, zoom, maxCoveringZoom, retain);
538
-
539
- for (const id in parentsForFading) {
540
- if (!retain[id]) {
541
- // If a tile is only needed for fading, mark it as covered so that it isn't rendered on it's own.
542
- this._coveredTiles[id] = true;
543
- retain[id] = parentsForFading[id];
544
- }
545
- }
546
- }
547
-
548
- for (const retainedId in retain) {
549
- // Make sure retained tiles always clear any existing fade holds
550
- // so that if they're removed again their fade timer starts fresh.
551
- this._tiles[retainedId].clearFadeHold();
552
- }
553
-
554
- // Remove the tiles we don't need anymore.
555
- const remove = keysDifference(this._tiles, retain);
556
- for (const tileID of remove) {
557
- const tile = this._tiles[tileID];
558
- if (tile.hasSymbolBuckets && !tile.holdingForFade()) {
559
- tile.setHoldDuration(this.map._fadeDuration);
560
- } else if (!tile.hasSymbolBuckets || tile.symbolFadeFinished()) {
561
- this._removeTile(tileID);
562
- }
563
- }
564
-
565
- // Construct a cache of loaded parents
566
- this._updateLoadedParentTileCache();
567
- }
568
-
569
- releaseSymbolFadeTiles() {
570
- for (const id in this._tiles) {
571
- if (this._tiles[id].holdingForFade()) {
572
- this._removeTile(id);
573
- }
574
- }
575
- }
576
-
577
- _updateRetainedTiles(idealTileIDs: Array<OverscaledTileID>, zoom: number): {[_: string]: OverscaledTileID} {
578
- const retain: {[_: string]: OverscaledTileID} = {};
579
- const checked: {[_: string]: boolean } = {};
580
- const minCoveringZoom = Math.max(zoom - SourceCache.maxOverzooming, this._source.minzoom);
581
- const maxCoveringZoom = Math.max(zoom + SourceCache.maxUnderzooming, this._source.minzoom);
582
-
583
- const missingTiles = {};
584
- for (const tileID of idealTileIDs) {
585
- const tile = this._addTile(tileID);
586
-
587
- // retain the tile even if it's not loaded because it's an ideal tile.
588
- retain[tileID.key] = tileID;
589
-
590
- if (tile.hasData()) continue;
591
-
592
- if (zoom < this._source.maxzoom) {
593
- // save missing tiles that potentially have loaded children
594
- missingTiles[tileID.key] = tileID;
595
- }
596
- }
597
-
598
- // retain any loaded children of ideal tiles up to maxCoveringZoom
599
- this._retainLoadedChildren(missingTiles, zoom, maxCoveringZoom, retain);
600
-
601
- for (const tileID of idealTileIDs) {
602
- let tile = this._tiles[tileID.key];
603
-
604
- if (tile.hasData()) continue;
605
-
606
- // The tile we require is not yet loaded or does not exist;
607
- // Attempt to find children that fully cover it.
608
-
609
- if (zoom + 1 > this._source.maxzoom) {
610
- // We're looking for an overzoomed child tile.
611
- const childCoord = tileID.children(this._source.maxzoom)[0];
612
- const childTile = this.getTile(childCoord);
613
- if (!!childTile && childTile.hasData()) {
614
- retain[childCoord.key] = childCoord;
615
- continue; // tile is covered by overzoomed child
616
- }
617
- } else {
618
- // check if all 4 immediate children are loaded (i.e. the missing ideal tile is covered)
619
- const children = tileID.children(this._source.maxzoom);
620
-
621
- if (retain[children[0].key] &&
622
- retain[children[1].key] &&
623
- retain[children[2].key] &&
624
- retain[children[3].key]) continue; // tile is covered by children
625
- }
626
-
627
- // We couldn't find child tiles that entirely cover the ideal tile; look for parents now.
628
-
629
- // As we ascend up the tile pyramid of the ideal tile, we check whether the parent
630
- // tile has been previously requested (and errored because we only loop over tiles with no data)
631
- // in order to determine if we need to request its parent.
632
- let parentWasRequested = tile.wasRequested();
633
-
634
- for (let overscaledZ = tileID.overscaledZ - 1; overscaledZ >= minCoveringZoom; --overscaledZ) {
635
- const parentId = tileID.scaledTo(overscaledZ);
636
-
637
- // Break parent tile ascent if this route has been previously checked by another child.
638
- if (checked[parentId.key]) break;
639
- checked[parentId.key] = true;
640
-
641
- tile = this.getTile(parentId);
642
- if (!tile && parentWasRequested) {
643
- tile = this._addTile(parentId);
644
- }
645
- if (tile) {
646
- retain[parentId.key] = parentId;
647
- // Save the current values, since they're the parent of the next iteration
648
- // of the parent tile ascent loop.
649
- parentWasRequested = tile.wasRequested();
650
- if (tile.hasData()) break;
651
- }
652
- }
653
- }
654
-
655
- return retain;
656
- }
657
-
658
- _updateLoadedParentTileCache() {
659
- this._loadedParentTiles = {};
660
-
661
- for (const tileKey in this._tiles) {
662
- const path = [];
663
- let parentTile: ?Tile;
664
- let currentId = this._tiles[tileKey].tileID;
665
-
666
- // Find the closest loaded ancestor by traversing the tile tree towards the root and
667
- // caching results along the way
668
- while (currentId.overscaledZ > 0) {
669
-
670
- // Do we have a cached result from previous traversals?
671
- if (currentId.key in this._loadedParentTiles) {
672
- parentTile = this._loadedParentTiles[currentId.key];
673
- break;
674
- }
675
-
676
- path.push(currentId.key);
677
-
678
- // Is the parent loaded?
679
- const parentId = currentId.scaledTo(currentId.overscaledZ - 1);
680
- parentTile = this._getLoadedTile(parentId);
681
- if (parentTile) {
682
- break;
683
- }
684
-
685
- currentId = parentId;
686
- }
687
-
688
- // Cache the result of this traversal to all newly visited tiles
689
- for (const key of path) {
690
- this._loadedParentTiles[key] = parentTile;
691
- }
692
- }
693
- }
694
-
695
- /**
696
- * Add a tile, given its coordinate, to the pyramid.
697
- * @private
698
- */
699
- _addTile(tileID: OverscaledTileID): Tile {
700
- let tile = this._tiles[tileID.key];
701
- if (tile) {
702
- return tile;
703
- } else {
704
- }
705
-
706
- tile = this._cache.getAndRemove(tileID);
707
- if (tile) {
708
- this._setTileReloadTimer(tileID.key, tile);
709
- // set the tileID because the cached tile could have had a different wrap value
710
- tile.tileID = tileID;
711
- this._state.initializeTileState(tile, this.map ? this.map.painter : null);
712
- if (this._cacheTimers[tileID.key]) {
713
- clearTimeout(this._cacheTimers[tileID.key]);
714
- delete this._cacheTimers[tileID.key];
715
- this._setTileReloadTimer(tileID.key, tile);
716
- }
717
- }
718
-
719
- const cached = Boolean(tile);
720
- if (!cached) {
721
- tile = new Tile(tileID, this._source.tileSize * tileID.overscaleFactor());
722
- this._loadTile(tile, this._tileLoaded.bind(this, tile, tileID.key, tile.state));
723
- }
724
-
725
- // Impossible, but silence flow.
726
- if (!tile) return (null: any);
727
-
728
- tile.uses++;
729
- this._tiles[tileID.key] = tile;
730
- if (!cached) this._source.fire(new Event('dataloading', {tile, coord: tile.tileID, dataType: 'source'}));
731
-
732
- return tile;
733
- }
734
-
735
- _setTileReloadTimer(id: string, tile: Tile) {
736
- if (id in this._timers) {
737
- clearTimeout(this._timers[id]);
738
- delete this._timers[id];
739
- }
740
-
741
- const expiryTimeout = tile.getExpiryTimeout();
742
- if (expiryTimeout) {
743
- this._timers[id] = setTimeout(() => {
744
- this._reloadTile(id, 'expired');
745
- delete this._timers[id];
746
- }, expiryTimeout);
747
- }
748
- }
749
-
750
- /**
751
- * Remove a tile, given its id, from the pyramid
752
- * @private
753
- */
754
- _removeTile(id: string) {
755
- const tile = this._tiles[id];
756
- if (!tile)
757
- return;
758
-
759
- tile.uses--;
760
- delete this._tiles[id];
761
- if (this._timers[id]) {
762
- clearTimeout(this._timers[id]);
763
- delete this._timers[id];
764
- }
765
-
766
- if (tile.uses > 0)
767
- return;
768
-
769
- if (tile.hasData() && tile.state !== 'reloading') {
770
- this._cache.add(tile.tileID, tile, tile.getExpiryTimeout());
771
- } else {
772
- tile.aborted = true;
773
- this._abortTile(tile);
774
- this._unloadTile(tile);
775
- }
776
- }
777
-
778
- /**
779
- * Remove all tiles from this pyramid
780
- */
781
- clearTiles() {
782
- this._shouldReloadOnResume = false;
783
- this._paused = false;
784
-
785
- for (const id in this._tiles)
786
- this._removeTile(id);
787
-
788
- this._cache.reset();
789
- }
790
-
791
- /**
792
- * Search through our current tiles and attempt to find the tiles that
793
- * cover the given bounds.
794
- * @param pointQueryGeometry coordinates of the corners of bounding rectangle
795
- * @returns {Array<Object>} result items have {tile, minX, maxX, minY, maxY}, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile.
796
- * @private
797
- */
798
- tilesIn(pointQueryGeometry: Array<Point>, maxPitchScaleFactor: number, has3DLayer: boolean) {
799
-
800
- const tileResults = [];
801
-
802
- const transform = this.transform;
803
- if (!transform) return tileResults;
804
-
805
- const cameraPointQueryGeometry = has3DLayer ?
806
- transform.getCameraQueryGeometry(pointQueryGeometry) :
807
- pointQueryGeometry;
808
-
809
- const queryGeometry = pointQueryGeometry.map((p) => transform.pointCoordinate(p));
810
- const cameraQueryGeometry = cameraPointQueryGeometry.map((p) => transform.pointCoordinate(p));
811
-
812
- const ids = this.getIds();
813
-
814
- let minX = Infinity;
815
- let minY = Infinity;
816
- let maxX = -Infinity;
817
- let maxY = -Infinity;
818
-
819
- for (const p of cameraQueryGeometry) {
820
- minX = Math.min(minX, p.x);
821
- minY = Math.min(minY, p.y);
822
- maxX = Math.max(maxX, p.x);
823
- maxY = Math.max(maxY, p.y);
824
- }
825
-
826
- for (let i = 0; i < ids.length; i++) {
827
- const tile = this._tiles[ids[i]];
828
- if (tile.holdingForFade()) {
829
- // Tiles held for fading are covered by tiles that are closer to ideal
830
- continue;
831
- }
832
- const tileID = tile.tileID;
833
- const scale = Math.pow(2, transform.zoom - tile.tileID.overscaledZ);
834
- const queryPadding = maxPitchScaleFactor * tile.queryPadding * EXTENT / tile.tileSize / scale;
835
-
836
- const tileSpaceBounds = [
837
- tileID.getTilePoint(new MercatorCoordinate(minX, minY)),
838
- tileID.getTilePoint(new MercatorCoordinate(maxX, maxY))
839
- ];
840
-
841
- if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT &&
842
- tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) {
843
-
844
- const tileSpaceQueryGeometry: Array<Point> = queryGeometry.map((c) => tileID.getTilePoint(c));
845
- const tileSpaceCameraQueryGeometry = cameraQueryGeometry.map((c) => tileID.getTilePoint(c));
846
-
847
- tileResults.push({
848
- tile,
849
- tileID,
850
- queryGeometry: tileSpaceQueryGeometry,
851
- cameraQueryGeometry: tileSpaceCameraQueryGeometry,
852
- scale
853
- });
854
- }
855
- }
856
-
857
- return tileResults;
858
- }
859
-
860
- getVisibleCoordinates(symbolLayer?: boolean): Array<OverscaledTileID> {
861
- const coords = this.getRenderableIds(symbolLayer).map((id) => {
862
- return this._tiles[id].tileID
863
- });
864
- for (const coord of coords) {
865
- coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped());
866
- }
867
- return coords;
868
- }
869
-
870
- hasTransition() {
871
- if (this._source.hasTransition()) {
872
- return true;
873
- }
874
-
875
- if (isRasterType(this._source.type)) {
876
- for (const id in this._tiles) {
877
- const tile = this._tiles[id];
878
- if (tile.fadeEndTime !== undefined && tile.fadeEndTime >= browser.now()) {
879
- return true;
880
- }
881
- }
882
- }
883
-
884
- return false;
885
- }
886
-
887
- /**
888
- * Set the value of a particular state for a feature
889
- * @private
890
- */
891
- setFeatureState(sourceLayer?: string, featureId: number | string, state: Object) {
892
- sourceLayer = sourceLayer || '_geojsonTileLayer';
893
- this._state.updateState(sourceLayer, featureId, state);
894
- }
895
-
896
- /**
897
- * Resets the value of a particular state key for a feature
898
- * @private
899
- */
900
- removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {
901
- sourceLayer = sourceLayer || '_geojsonTileLayer';
902
- this._state.removeFeatureState(sourceLayer, featureId, key);
903
- }
904
-
905
- /**
906
- * Get the entire state object for a feature
907
- * @private
908
- */
909
- getFeatureState(sourceLayer?: string, featureId: number | string) {
910
- sourceLayer = sourceLayer || '_geojsonTileLayer';
911
- return this._state.getState(sourceLayer, featureId);
912
- }
913
-
914
- /**
915
- * Sets the set of keys that the tile depends on. This allows tiles to
916
- * be reloaded when their dependencies change.
917
- * @private
918
- */
919
- setDependencies(tileKey: string, namespace: string, dependencies: Array<string>) {
920
- const tile = this._tiles[tileKey];
921
- if (tile) {
922
- tile.setDependencies(namespace, dependencies);
923
- }
924
- }
925
-
926
- /**
927
- * Reloads all tiles that depend on the given keys.
928
- * @private
929
- */
930
- reloadTilesForDependencies(namespaces: Array<string>, keys: Array<string>) {
931
- for (const id in this._tiles) {
932
- const tile = this._tiles[id];
933
- if (tile.hasDependency(namespaces, keys)) {
934
- this._reloadTile(id, 'reloading');
935
- }
936
- }
937
- this._cache.filter(tile => !tile.hasDependency(namespaces, keys));
938
- }
939
- }
940
-
941
- SourceCache.maxOverzooming = 10;
942
- SourceCache.maxUnderzooming = 3;
943
-
944
- function compareTileId(a: OverscaledTileID, b: OverscaledTileID): number {
945
- // Different copies of the world are sorted based on their distance to the center.
946
- // Wrap values are converted to unsigned distances by reserving odd number for copies
947
- // with negative wrap and even numbers for copies with positive wrap.
948
- const aWrap = Math.abs(a.wrap * 2) - +(a.wrap < 0);
949
- const bWrap = Math.abs(b.wrap * 2) - +(b.wrap < 0);
950
- return a.overscaledZ - b.overscaledZ || bWrap - aWrap || b.canonical.y - a.canonical.y || b.canonical.x - a.canonical.x;
951
- }
952
-
953
- function isRasterType(type) {
954
- return type === 'raster' || type === 'image' || type === 'video';
955
- }
956
-
957
- export default SourceCache;