maplibre-gl 3.1.0 → 3.2.0-pre.2
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.
- package/README.md +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-struct-arrays.ts +9 -12
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3303 -3398
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3899 -3531
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +28 -25
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +36 -26
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +61 -44
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +34 -27
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +12 -11
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/value.ts +1 -1
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +8 -14
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +12 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +85 -65
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +18 -16
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +5 -4
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +7 -1
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/shaders.ts +1 -3
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +75 -59
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +23 -10
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +17 -38
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +34 -24
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +11 -23
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +21 -28
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +39 -33
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +23 -48
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +392 -361
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +21 -26
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +181 -194
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +46 -42
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +14 -18
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +570 -1281
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +97 -8
- package/src/ui/map.ts +856 -702
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +220 -141
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +179 -147
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +2 -6
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +6 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +6 -0
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +2 -4
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
package/src/source/tile.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {uniqueId, parseCacheControl} from '../util/util';
|
|
2
2
|
import {deserialize as deserializeBucket} from '../data/bucket';
|
|
3
3
|
import '../data/feature_index';
|
|
4
|
-
import type FeatureIndex from '../data/feature_index';
|
|
5
|
-
import GeoJSONFeature from '../util/vectortile_to_geojson';
|
|
4
|
+
import type {FeatureIndex} from '../data/feature_index';
|
|
5
|
+
import {GeoJSONFeature} from '../util/vectortile_to_geojson';
|
|
6
6
|
import {featureFilter} from '@maplibre/maplibre-gl-style-spec';
|
|
7
|
-
import SymbolBucket from '../data/bucket/symbol_bucket';
|
|
7
|
+
import {SymbolBucket} from '../data/bucket/symbol_bucket';
|
|
8
8
|
import {CollisionBoxArray} from '../data/array_types.g';
|
|
9
|
-
import Texture from '../render/texture';
|
|
10
|
-
import browser from '../util/browser';
|
|
11
|
-
import toEvaluationFeature from '../data/evaluation_feature';
|
|
12
|
-
import EvaluationParameters from '../style/evaluation_parameters';
|
|
13
|
-
import SourceFeatureState from '../source/source_state';
|
|
9
|
+
import {Texture} from '../render/texture';
|
|
10
|
+
import {browser} from '../util/browser';
|
|
11
|
+
import {toEvaluationFeature} from '../data/evaluation_feature';
|
|
12
|
+
import {EvaluationParameters} from '../style/evaluation_parameters';
|
|
13
|
+
import {SourceFeatureState} from '../source/source_state';
|
|
14
14
|
import {lazyLoadRTLTextPlugin} from './rtl_text_plugin';
|
|
15
15
|
|
|
16
16
|
const CLOCK_SKEW_RETRY_TIMEOUT = 30000;
|
|
17
17
|
|
|
18
18
|
import type {Bucket} from '../data/bucket';
|
|
19
|
-
import type StyleLayer from '../style/style_layer';
|
|
19
|
+
import type {StyleLayer} from '../style/style_layer';
|
|
20
20
|
import type {WorkerTileResult} from './worker_source';
|
|
21
|
-
import type Actor from '../util/actor';
|
|
22
|
-
import type DEMData from '../data/dem_data';
|
|
21
|
+
import type {Actor} from '../util/actor';
|
|
22
|
+
import type {DEMData} from '../data/dem_data';
|
|
23
23
|
import type {AlphaImage} from '../util/image';
|
|
24
|
-
import type ImageAtlas from '../render/image_atlas';
|
|
25
|
-
import type ImageManager from '../render/image_manager';
|
|
26
|
-
import type Context from '../gl/context';
|
|
24
|
+
import type {ImageAtlas} from '../render/image_atlas';
|
|
25
|
+
import type {ImageManager} from '../render/image_manager';
|
|
26
|
+
import type {Context} from '../gl/context';
|
|
27
27
|
import type {OverscaledTileID} from './tile_id';
|
|
28
|
-
import type Framebuffer from '../gl/framebuffer';
|
|
29
|
-
import type Transform from '../geo/transform';
|
|
28
|
+
import type {Framebuffer} from '../gl/framebuffer';
|
|
29
|
+
import type {Transform} from '../geo/transform';
|
|
30
30
|
import type {LayerFeatureStates} from './source_state';
|
|
31
31
|
import type {Cancelable} from '../types/cancelable';
|
|
32
32
|
import type {FilterSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
@@ -35,21 +35,22 @@ import {mat4} from 'gl-matrix';
|
|
|
35
35
|
import type {VectorTileLayer} from '@mapbox/vector-tile';
|
|
36
36
|
import {ExpiryData} from '../util/ajax';
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The tile's state, can be:
|
|
40
|
+
* - `loading` Tile data is in the process of loading.
|
|
41
|
+
* - `loaded` Tile data has been loaded. Tile can be rendered.
|
|
42
|
+
* - `reloading` Tile data has been loaded and is being updated. Tile can be rendered.
|
|
43
|
+
* - `unloaded` Tile data has been deleted.
|
|
44
|
+
* - `errored` Tile data was not loaded because of an error.
|
|
45
|
+
* - `expired` Tile data was previously loaded, but has expired per its HTTP headers and is in the process of refreshing.
|
|
46
|
+
*/
|
|
47
|
+
export type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired';
|
|
45
48
|
|
|
46
49
|
/**
|
|
47
50
|
* A tile object is the combination of a Coordinate, which defines
|
|
48
51
|
* its place, as well as a unique ID and data tracking for its content
|
|
49
|
-
*
|
|
50
|
-
* @private
|
|
51
52
|
*/
|
|
52
|
-
class Tile {
|
|
53
|
+
export class Tile {
|
|
53
54
|
tileID: OverscaledTileID;
|
|
54
55
|
uid: number;
|
|
55
56
|
uses: number;
|
|
@@ -96,9 +97,8 @@ class Tile {
|
|
|
96
97
|
rttCoords: {[_:string]: string};
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
|
-
* @param
|
|
100
|
-
* @param size
|
|
101
|
-
* @private
|
|
100
|
+
* @param tileID - the tile ID
|
|
101
|
+
* @param size - The tile size
|
|
102
102
|
*/
|
|
103
103
|
constructor(tileID: OverscaledTileID, size: number) {
|
|
104
104
|
this.tileID = tileID;
|
|
@@ -147,11 +147,9 @@ class Tile {
|
|
|
147
147
|
* this tile's elementGroups and buffers properties and set loaded
|
|
148
148
|
* to true. If the data is null, like in the case of an empty
|
|
149
149
|
* GeoJSON tile, no-op but still set loaded to true.
|
|
150
|
-
* @param
|
|
151
|
-
* @param painter
|
|
152
|
-
* @param justReloaded
|
|
153
|
-
* @returns {undefined}
|
|
154
|
-
* @private
|
|
150
|
+
* @param data - The data from the worker
|
|
151
|
+
* @param painter - the painter
|
|
152
|
+
* @param justReloaded - `true` to just reload
|
|
155
153
|
*/
|
|
156
154
|
loadVectorData(data: WorkerTileResult, painter: any, justReloaded?: boolean | null) {
|
|
157
155
|
if (this.hasData()) {
|
|
@@ -225,8 +223,6 @@ class Tile {
|
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* Release any data or WebGL resources referenced by this tile.
|
|
228
|
-
* @returns {undefined}
|
|
229
|
-
* @private
|
|
230
226
|
*/
|
|
231
227
|
unloadVectorData() {
|
|
232
228
|
for (const id in this.buckets) {
|
|
@@ -480,5 +476,3 @@ class Tile {
|
|
|
480
476
|
return false;
|
|
481
477
|
}
|
|
482
478
|
}
|
|
483
|
-
|
|
484
|
-
export default Tile;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import LngLatBounds,
|
|
1
|
+
import {LngLatBounds, LngLatBoundsLike} from '../geo/lng_lat_bounds';
|
|
2
2
|
import {mercatorXfromLng, mercatorYfromLat} from '../geo/mercator_coordinate';
|
|
3
3
|
|
|
4
4
|
import type {CanonicalTileID} from './tile_id';
|
|
5
5
|
|
|
6
|
-
class TileBounds {
|
|
6
|
+
export class TileBounds {
|
|
7
7
|
bounds: LngLatBounds;
|
|
8
8
|
minzoom: number;
|
|
9
9
|
maxzoom: number;
|
|
@@ -32,5 +32,3 @@ class TileBounds {
|
|
|
32
32
|
return hit;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
export default TileBounds;
|
package/src/source/tile_cache.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {OverscaledTileID} from './tile_id';
|
|
2
|
-
import type Tile from './tile';
|
|
2
|
+
import type {Tile} from './tile';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)
|
|
6
6
|
* with hash lookup made possible by keeping a list of keys in parallel to
|
|
7
7
|
* an array of dictionary of values
|
|
8
8
|
*
|
|
9
|
-
* @private
|
|
10
9
|
*/
|
|
11
|
-
class TileCache {
|
|
10
|
+
export class TileCache {
|
|
12
11
|
max: number;
|
|
13
12
|
data: {
|
|
14
13
|
[key: string]: Array<{
|
|
@@ -19,8 +18,8 @@ class TileCache {
|
|
|
19
18
|
order: Array<string>;
|
|
20
19
|
onRemove: (element: Tile) => void;
|
|
21
20
|
/**
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
21
|
+
* @param max - number of permitted values
|
|
22
|
+
* @param onRemove - callback called with items when they expire
|
|
24
23
|
*/
|
|
25
24
|
constructor(max: number, onRemove: (element: Tile) => void) {
|
|
26
25
|
this.max = max;
|
|
@@ -31,8 +30,7 @@ class TileCache {
|
|
|
31
30
|
/**
|
|
32
31
|
* Clear the cache
|
|
33
32
|
*
|
|
34
|
-
* @returns
|
|
35
|
-
* @private
|
|
33
|
+
* @returns this cache
|
|
36
34
|
*/
|
|
37
35
|
reset() {
|
|
38
36
|
for (const key in this.data) {
|
|
@@ -52,11 +50,10 @@ class TileCache {
|
|
|
52
50
|
* Add a key, value combination to the cache, trimming its size if this pushes
|
|
53
51
|
* it over max length.
|
|
54
52
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
53
|
+
* @param tileID - lookup key for the item
|
|
54
|
+
* @param data - tile data
|
|
57
55
|
*
|
|
58
|
-
* @returns
|
|
59
|
-
* @private
|
|
56
|
+
* @returns this cache
|
|
60
57
|
*/
|
|
61
58
|
add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) {
|
|
62
59
|
const key = tileID.wrapped().key;
|
|
@@ -89,9 +86,8 @@ class TileCache {
|
|
|
89
86
|
/**
|
|
90
87
|
* Determine whether the value attached to `key` is present
|
|
91
88
|
*
|
|
92
|
-
* @param
|
|
93
|
-
* @returns
|
|
94
|
-
* @private
|
|
89
|
+
* @param tileID - the key to be looked-up
|
|
90
|
+
* @returns whether the cache has this value
|
|
95
91
|
*/
|
|
96
92
|
has(tileID: OverscaledTileID): boolean {
|
|
97
93
|
return tileID.wrapped().key in this.data;
|
|
@@ -101,9 +97,8 @@ class TileCache {
|
|
|
101
97
|
* Get the value attached to a specific key and remove data from cache.
|
|
102
98
|
* If the key is not found, returns `null`
|
|
103
99
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @returns
|
|
106
|
-
* @private
|
|
100
|
+
* @param tileID - the key to look up
|
|
101
|
+
* @returns the tile data, or null if it isn't found
|
|
107
102
|
*/
|
|
108
103
|
getAndRemove(tileID: OverscaledTileID): Tile {
|
|
109
104
|
if (!this.has(tileID)) { return null; }
|
|
@@ -137,9 +132,8 @@ class TileCache {
|
|
|
137
132
|
* Get the value attached to a specific key without removing data
|
|
138
133
|
* from the cache. If the key is not found, returns `null`
|
|
139
134
|
*
|
|
140
|
-
* @param
|
|
141
|
-
* @returns
|
|
142
|
-
* @private
|
|
135
|
+
* @param tileID - the key to look up
|
|
136
|
+
* @returns the tile data, or null if it isn't found
|
|
143
137
|
*/
|
|
144
138
|
get(tileID: OverscaledTileID): Tile {
|
|
145
139
|
if (!this.has(tileID)) { return null; }
|
|
@@ -151,10 +145,9 @@ class TileCache {
|
|
|
151
145
|
/**
|
|
152
146
|
* Remove a key/value combination from the cache.
|
|
153
147
|
*
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
156
|
-
* @returns
|
|
157
|
-
* @private
|
|
148
|
+
* @param tileID - the key for the pair to delete
|
|
149
|
+
* @param value - If a value is provided, remove that exact version of the value.
|
|
150
|
+
* @returns this cache
|
|
158
151
|
*/
|
|
159
152
|
remove(tileID: OverscaledTileID, value?: {
|
|
160
153
|
value: Tile;
|
|
@@ -179,9 +172,8 @@ class TileCache {
|
|
|
179
172
|
/**
|
|
180
173
|
* Change the max size of the cache.
|
|
181
174
|
*
|
|
182
|
-
* @param
|
|
183
|
-
* @returns
|
|
184
|
-
* @private
|
|
175
|
+
* @param max - the max size of the cache
|
|
176
|
+
* @returns this cache
|
|
185
177
|
*/
|
|
186
178
|
setMaxSize(max: number): TileCache {
|
|
187
179
|
this.max = max;
|
|
@@ -198,7 +190,7 @@ class TileCache {
|
|
|
198
190
|
* Remove entries that do not pass a filter function. Used for removing
|
|
199
191
|
* stale tiles from the cache.
|
|
200
192
|
*
|
|
201
|
-
* @param
|
|
193
|
+
* @param filterFn - Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out.
|
|
202
194
|
*/
|
|
203
195
|
filter(filterFn: (tile: Tile) => boolean) {
|
|
204
196
|
const removed = [];
|
|
@@ -214,5 +206,3 @@ class TileCache {
|
|
|
214
206
|
}
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
|
-
|
|
218
|
-
export default TileCache;
|
package/src/source/tile_id.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {getTileBBox} from '@mapbox/whoots-js';
|
|
2
|
-
import EXTENT from '../data/extent';
|
|
2
|
+
import {EXTENT} from '../data/extent';
|
|
3
3
|
import Point from '@mapbox/point-geometry';
|
|
4
|
-
import MercatorCoordinate from '../geo/mercator_coordinate';
|
|
4
|
+
import {MercatorCoordinate} from '../geo/mercator_coordinate';
|
|
5
5
|
import {register} from '../util/web_worker_transfer';
|
|
6
6
|
import {mat4} from 'gl-matrix';
|
|
7
7
|
import {ICanonicalTileID, IMercatorCoordinate} from '@maplibre/maplibre-gl-style-spec';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A canonical way to define a tile ID
|
|
11
|
+
*/
|
|
9
12
|
export class CanonicalTileID implements ICanonicalTileID {
|
|
10
13
|
z: number;
|
|
11
14
|
x: number;
|
|
@@ -60,6 +63,9 @@ export class CanonicalTileID implements ICanonicalTileID {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
/**
|
|
67
|
+
* An unwrapped tile identifier
|
|
68
|
+
*/
|
|
63
69
|
export class UnwrappedTileID {
|
|
64
70
|
wrap: number;
|
|
65
71
|
canonical: CanonicalTileID;
|
|
@@ -72,6 +78,9 @@ export class UnwrappedTileID {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
* An overscaled tile identifier
|
|
83
|
+
*/
|
|
75
84
|
export class OverscaledTileID {
|
|
76
85
|
overscaledZ: number;
|
|
77
86
|
wrap: number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {fakeServer, FakeServer} from 'nise';
|
|
2
2
|
import {Source} from './source';
|
|
3
|
-
import VectorTileSource from './vector_tile_source';
|
|
4
|
-
import Tile from './tile';
|
|
3
|
+
import {VectorTileSource} from './vector_tile_source';
|
|
4
|
+
import {Tile} from './tile';
|
|
5
5
|
import {OverscaledTileID} from './tile_id';
|
|
6
6
|
import {Evented} from '../util/evented';
|
|
7
7
|
import {RequestManager} from '../util/request_manager';
|
|
8
8
|
import fixturesSource from '../../test/unit/assets/source.json' assert {type: 'json'};
|
|
9
9
|
import {getMockDispatcher, getWrapDispatcher} from '../util/test/util';
|
|
10
|
-
import Map from '../ui/map';
|
|
10
|
+
import {Map} from '../ui/map';
|
|
11
11
|
|
|
12
12
|
function createSource(options, transformCallback?, clearTiles = () => {}) {
|
|
13
13
|
const source = new VectorTileSource('id', options, getMockDispatcher(), options.eventedParent);
|
|
@@ -1,46 +1,60 @@
|
|
|
1
1
|
import {Event, ErrorEvent, Evented} from '../util/evented';
|
|
2
2
|
|
|
3
3
|
import {extend, pick} from '../util/util';
|
|
4
|
-
import
|
|
5
|
-
import TileBounds from './tile_bounds';
|
|
4
|
+
import {loadTileJson} from './load_tilejson';
|
|
5
|
+
import {TileBounds} from './tile_bounds';
|
|
6
6
|
import {ResourceType} from '../util/request_manager';
|
|
7
7
|
|
|
8
8
|
import type {Source} from './source';
|
|
9
9
|
import type {OverscaledTileID} from './tile_id';
|
|
10
|
-
import type Map from '../ui/map';
|
|
11
|
-
import type Dispatcher from '../util/dispatcher';
|
|
12
|
-
import type Tile from './tile';
|
|
10
|
+
import type {Map} from '../ui/map';
|
|
11
|
+
import type {Dispatcher} from '../util/dispatcher';
|
|
12
|
+
import type {Tile} from './tile';
|
|
13
13
|
import type {Callback} from '../types/callback';
|
|
14
14
|
import type {Cancelable} from '../types/cancelable';
|
|
15
15
|
import type {VectorSourceSpecification, PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
16
16
|
|
|
17
|
+
export type VectorTileSourceOptions = VectorSourceSpecification & {
|
|
18
|
+
collectResourceTiming?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
22
|
* A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/).
|
|
19
23
|
* (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)
|
|
20
24
|
*
|
|
25
|
+
* @group Sources
|
|
26
|
+
*
|
|
21
27
|
* @example
|
|
28
|
+
* ```ts
|
|
22
29
|
* map.addSource('some id', {
|
|
23
30
|
* type: 'vector',
|
|
24
31
|
* url: 'https://demotiles.maplibre.org/tiles/tiles.json'
|
|
25
32
|
* });
|
|
33
|
+
* ```
|
|
26
34
|
*
|
|
27
35
|
* @example
|
|
36
|
+
* ```ts
|
|
28
37
|
* map.addSource('some id', {
|
|
29
38
|
* type: 'vector',
|
|
30
39
|
* tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],
|
|
31
40
|
* minzoom: 6,
|
|
32
41
|
* maxzoom: 14
|
|
33
42
|
* });
|
|
43
|
+
* ```
|
|
34
44
|
*
|
|
35
45
|
* @example
|
|
46
|
+
* ```ts
|
|
36
47
|
* map.getSource('some id').setUrl("https://demotiles.maplibre.org/tiles/tiles.json");
|
|
48
|
+
* ```
|
|
37
49
|
*
|
|
38
50
|
* @example
|
|
51
|
+
* ```ts
|
|
39
52
|
* map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
|
|
40
|
-
*
|
|
41
|
-
* @see [Add a
|
|
53
|
+
* ```
|
|
54
|
+
* @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)
|
|
55
|
+
* @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
|
|
42
56
|
*/
|
|
43
|
-
class VectorTileSource extends Evented implements Source {
|
|
57
|
+
export class VectorTileSource extends Evented implements Source {
|
|
44
58
|
type: 'vector';
|
|
45
59
|
id: string;
|
|
46
60
|
minzoom: number;
|
|
@@ -62,9 +76,7 @@ class VectorTileSource extends Evented implements Source {
|
|
|
62
76
|
_tileJSONRequest: Cancelable;
|
|
63
77
|
_loaded: boolean;
|
|
64
78
|
|
|
65
|
-
constructor(id: string, options:
|
|
66
|
-
collectResourceTiming: boolean;
|
|
67
|
-
}, dispatcher: Dispatcher, eventedParent: Evented) {
|
|
79
|
+
constructor(id: string, options: VectorTileSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {
|
|
68
80
|
super();
|
|
69
81
|
this.id = id;
|
|
70
82
|
this.dispatcher = dispatcher;
|
|
@@ -90,10 +102,10 @@ class VectorTileSource extends Evented implements Source {
|
|
|
90
102
|
this.setEventedParent(eventedParent);
|
|
91
103
|
}
|
|
92
104
|
|
|
93
|
-
load() {
|
|
105
|
+
load = () => {
|
|
94
106
|
this._loaded = false;
|
|
95
107
|
this.fire(new Event('dataloading', {dataType: 'source'}));
|
|
96
|
-
this._tileJSONRequest =
|
|
108
|
+
this._tileJSONRequest = loadTileJson(this._options, this.map._requestManager, (err, tileJSON) => {
|
|
97
109
|
this._tileJSONRequest = null;
|
|
98
110
|
this._loaded = true;
|
|
99
111
|
this.map.style.sourceCaches[this.id].clearTiles();
|
|
@@ -110,7 +122,7 @@ class VectorTileSource extends Evented implements Source {
|
|
|
110
122
|
this.fire(new Event('data', {dataType: 'source', sourceDataType: 'content'}));
|
|
111
123
|
}
|
|
112
124
|
});
|
|
113
|
-
}
|
|
125
|
+
};
|
|
114
126
|
|
|
115
127
|
loaded(): boolean {
|
|
116
128
|
return this._loaded;
|
|
@@ -138,10 +150,10 @@ class VectorTileSource extends Evented implements Source {
|
|
|
138
150
|
/**
|
|
139
151
|
* Sets the source `tiles` property and re-renders the map.
|
|
140
152
|
*
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
153
|
+
* @param tiles - An array of one or more tile source URLs, as in the TileJSON spec.
|
|
154
|
+
* @returns `this`
|
|
143
155
|
*/
|
|
144
|
-
setTiles(tiles: Array<string>) {
|
|
156
|
+
setTiles(tiles: Array<string>): this {
|
|
145
157
|
this.setSourceProperty(() => {
|
|
146
158
|
this._options.tiles = tiles;
|
|
147
159
|
});
|
|
@@ -152,10 +164,10 @@ class VectorTileSource extends Evented implements Source {
|
|
|
152
164
|
/**
|
|
153
165
|
* Sets the source `url` property and re-renders the map.
|
|
154
166
|
*
|
|
155
|
-
* @param
|
|
156
|
-
* @returns
|
|
167
|
+
* @param url - A URL to a TileJSON resource. Supported protocols are `http:` and `https:`.
|
|
168
|
+
* @returns `this`
|
|
157
169
|
*/
|
|
158
|
-
setUrl(url: string) {
|
|
170
|
+
setUrl(url: string): this {
|
|
159
171
|
this.setSourceProperty(() => {
|
|
160
172
|
this.url = url;
|
|
161
173
|
this._options.url = url;
|
|
@@ -171,9 +183,9 @@ class VectorTileSource extends Evented implements Source {
|
|
|
171
183
|
}
|
|
172
184
|
}
|
|
173
185
|
|
|
174
|
-
serialize() {
|
|
186
|
+
serialize = (): VectorSourceSpecification => {
|
|
175
187
|
return extend({}, this._options);
|
|
176
|
-
}
|
|
188
|
+
};
|
|
177
189
|
|
|
178
190
|
loadTile(tile: Tile, callback: Callback<void>) {
|
|
179
191
|
const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
|
|
@@ -247,5 +259,3 @@ class VectorTileSource extends Evented implements Source {
|
|
|
247
259
|
return false;
|
|
248
260
|
}
|
|
249
261
|
}
|
|
250
|
-
|
|
251
|
-
export default VectorTileSource;
|
|
@@ -2,12 +2,12 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import vt from '@mapbox/vector-tile';
|
|
4
4
|
import Protobuf from 'pbf';
|
|
5
|
-
import VectorTileWorkerSource from '../source/vector_tile_worker_source';
|
|
6
|
-
import StyleLayerIndex from '../style/style_layer_index';
|
|
5
|
+
import {VectorTileWorkerSource} from '../source/vector_tile_worker_source';
|
|
6
|
+
import {StyleLayerIndex} from '../style/style_layer_index';
|
|
7
7
|
import {fakeServer, FakeServer} from 'nise';
|
|
8
|
-
import Actor from '../util/actor';
|
|
8
|
+
import {Actor} from '../util/actor';
|
|
9
9
|
import {TileParameters, WorkerTileParameters} from './worker_source';
|
|
10
|
-
import WorkerTile from './worker_tile';
|
|
10
|
+
import {WorkerTile} from './worker_tile';
|
|
11
11
|
import {setPerformance} from '../util/test/util';
|
|
12
12
|
|
|
13
13
|
describe('vector tile worker source', () => {
|
|
@@ -2,7 +2,7 @@ import {ExpiryData, getArrayBuffer} from '../util/ajax';
|
|
|
2
2
|
|
|
3
3
|
import vt from '@mapbox/vector-tile';
|
|
4
4
|
import Protobuf from 'pbf';
|
|
5
|
-
import WorkerTile from './worker_tile';
|
|
5
|
+
import {WorkerTile} from './worker_tile';
|
|
6
6
|
import {extend} from '../util/util';
|
|
7
7
|
import {RequestPerformance} from '../util/performance';
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ import type {
|
|
|
13
13
|
TileParameters
|
|
14
14
|
} from '../source/worker_source';
|
|
15
15
|
|
|
16
|
-
import type Actor from '../util/actor';
|
|
17
|
-
import type StyleLayerIndex from '../style/style_layer_index';
|
|
16
|
+
import type {Actor} from '../util/actor';
|
|
17
|
+
import type {StyleLayerIndex} from '../style/style_layer_index';
|
|
18
18
|
import type {Callback} from '../types/callback';
|
|
19
19
|
import type {VectorTile} from '@mapbox/vector-tile';
|
|
20
20
|
|
|
@@ -25,10 +25,7 @@ export type LoadVectorTileResult = {
|
|
|
25
25
|
} & ExpiryData;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param error
|
|
30
|
-
* @param vectorTile
|
|
31
|
-
* @private
|
|
28
|
+
* The callback when finished loading vector data
|
|
32
29
|
*/
|
|
33
30
|
export type LoadVectorDataCallback = Callback<LoadVectorTileResult>;
|
|
34
31
|
|
|
@@ -36,7 +33,7 @@ export type AbortVectorData = () => void;
|
|
|
36
33
|
export type LoadVectorData = (params: WorkerTileParameters, callback: LoadVectorDataCallback) => AbortVectorData | void;
|
|
37
34
|
|
|
38
35
|
/**
|
|
39
|
-
*
|
|
36
|
+
* Loads a vector tile
|
|
40
37
|
*/
|
|
41
38
|
function loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCallback) {
|
|
42
39
|
const request = getArrayBuffer(params.request, (err?: Error | null, data?: ArrayBuffer | null, cacheControl?: string | null, expires?: string | null) => {
|
|
@@ -63,10 +60,8 @@ function loadVectorTile(params: WorkerTileParameters, callback: LoadVectorDataCa
|
|
|
63
60
|
* for data formats that can be parsed/converted into an in-memory VectorTile
|
|
64
61
|
* representation. To do so, create it with
|
|
65
62
|
* `new VectorTileWorkerSource(actor, styleLayers, customLoadVectorDataFunction)`.
|
|
66
|
-
*
|
|
67
|
-
* @private
|
|
68
63
|
*/
|
|
69
|
-
class VectorTileWorkerSource implements WorkerSource {
|
|
64
|
+
export class VectorTileWorkerSource implements WorkerSource {
|
|
70
65
|
actor: Actor;
|
|
71
66
|
layerIndex: StyleLayerIndex;
|
|
72
67
|
availableImages: Array<string>;
|
|
@@ -75,11 +70,10 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
75
70
|
loaded: {[_: string]: WorkerTile};
|
|
76
71
|
|
|
77
72
|
/**
|
|
78
|
-
* @param
|
|
73
|
+
* @param loadVectorData - Optional method for custom loading of a VectorTile
|
|
79
74
|
* object based on parameters passed from the main-thread Source. See
|
|
80
75
|
* {@link VectorTileWorkerSource#loadTile}. The default implementation simply
|
|
81
76
|
* loads the pbf at `params.url`.
|
|
82
|
-
* @private
|
|
83
77
|
*/
|
|
84
78
|
constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array<string>, loadVectorData?: LoadVectorData | null) {
|
|
85
79
|
this.actor = actor;
|
|
@@ -94,7 +88,6 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
94
88
|
* Implements {@link WorkerSource#loadTile}. Delegates to
|
|
95
89
|
* {@link VectorTileWorkerSource#loadVectorData} (which by default expects
|
|
96
90
|
* a `params.url` property) for fetching and producing a VectorTile object.
|
|
97
|
-
* @private
|
|
98
91
|
*/
|
|
99
92
|
loadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {
|
|
100
93
|
const uid = params.uid;
|
|
@@ -144,7 +137,6 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
144
137
|
|
|
145
138
|
/**
|
|
146
139
|
* Implements {@link WorkerSource#reloadTile}.
|
|
147
|
-
* @private
|
|
148
140
|
*/
|
|
149
141
|
reloadTile(params: WorkerTileParameters, callback: WorkerTileCallback) {
|
|
150
142
|
const loaded = this.loaded,
|
|
@@ -179,9 +171,8 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
179
171
|
/**
|
|
180
172
|
* Implements {@link WorkerSource#abortTile}.
|
|
181
173
|
*
|
|
182
|
-
* @param params
|
|
183
|
-
* @param
|
|
184
|
-
* @private
|
|
174
|
+
* @param params - The tile parameters
|
|
175
|
+
* @param callback - The callback
|
|
185
176
|
*/
|
|
186
177
|
abortTile(params: TileParameters, callback: WorkerTileCallback) {
|
|
187
178
|
const loading = this.loading,
|
|
@@ -196,9 +187,8 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
196
187
|
/**
|
|
197
188
|
* Implements {@link WorkerSource#removeTile}.
|
|
198
189
|
*
|
|
199
|
-
* @param params
|
|
200
|
-
* @param
|
|
201
|
-
* @private
|
|
190
|
+
* @param params - The tile parameters
|
|
191
|
+
* @param callback - The callback
|
|
202
192
|
*/
|
|
203
193
|
removeTile(params: TileParameters, callback: WorkerTileCallback) {
|
|
204
194
|
const loaded = this.loaded,
|
|
@@ -209,5 +199,3 @@ class VectorTileWorkerSource implements WorkerSource {
|
|
|
209
199
|
callback();
|
|
210
200
|
}
|
|
211
201
|
}
|
|
212
|
-
|
|
213
|
-
export default VectorTileWorkerSource;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import VideoSource from './video_source';
|
|
1
|
+
import {VideoSource} from './video_source';
|
|
2
2
|
import {extend} from '../util/util';
|
|
3
3
|
import {getMockDispatcher} from '../util/test/util';
|
|
4
4
|
|
|
5
5
|
import type {Coordinates} from './image_source';
|
|
6
|
-
import Tile from './tile';
|
|
6
|
+
import {Tile} from './tile';
|
|
7
7
|
import {OverscaledTileID} from './tile_id';
|
|
8
8
|
import {Evented} from '../util/evented';
|
|
9
|
-
import Transform from '../geo/transform';
|
|
10
|
-
import VertexBuffer from '../gl/vertex_buffer';
|
|
11
|
-
import SegmentVector from '../data/segment';
|
|
9
|
+
import {Transform} from '../geo/transform';
|
|
10
|
+
import {VertexBuffer} from '../gl/vertex_buffer';
|
|
11
|
+
import {SegmentVector} from '../data/segment';
|
|
12
12
|
|
|
13
13
|
class StubMap extends Evented {
|
|
14
14
|
transform: Transform;
|