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/source.ts
CHANGED
|
@@ -1,47 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {VectorTileSource} from '../source/vector_tile_source';
|
|
2
|
+
import {RasterTileSource} from '../source/raster_tile_source';
|
|
3
|
+
import {RasterDEMTileSource} from '../source/raster_dem_tile_source';
|
|
4
|
+
import {GeoJSONSource} from '../source/geojson_source';
|
|
5
|
+
import {VideoSource} from '../source/video_source';
|
|
6
|
+
import {ImageSource} from '../source/image_source';
|
|
7
|
+
import {CanvasSource} from '../source/canvas_source';
|
|
2
8
|
|
|
3
|
-
import type
|
|
9
|
+
import type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
10
|
+
import type {Dispatcher} from '../util/dispatcher';
|
|
4
11
|
import type {Event, Evented} from '../util/evented';
|
|
5
|
-
import type Map from '../ui/map';
|
|
6
|
-
import type Tile from './tile';
|
|
7
|
-
import type {OverscaledTileID} from './tile_id';
|
|
12
|
+
import type {Map} from '../ui/map';
|
|
13
|
+
import type {Tile} from './tile';
|
|
14
|
+
import type {OverscaledTileID, CanonicalTileID} from './tile_id';
|
|
8
15
|
import type {Callback} from '../types/callback';
|
|
9
|
-
import {
|
|
16
|
+
import type {CanvasSourceSpecification} from '../source/canvas_source';
|
|
17
|
+
|
|
18
|
+
const registeredSources = {} as {[key:string]: SourceClass};
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* The `Source` interface must be implemented by each source type, including "core" types (`vector`, `raster`,
|
|
13
22
|
* `video`, etc.) and all custom, third-party types.
|
|
14
23
|
*
|
|
15
|
-
* @
|
|
16
|
-
*
|
|
17
|
-
* @param {string} id The id for the source. Must not be used by any existing source.
|
|
18
|
-
* @param {Object} options Source options, specific to the source type (except for `options.type`, which is always
|
|
19
|
-
* required).
|
|
20
|
-
* @param {string} options.type The source type, matching the value of `name` used in {@link Style#addSourceType}.
|
|
21
|
-
* @param {Dispatcher} dispatcher A {@link Dispatcher} instance, which can be used to send messages to the workers.
|
|
22
|
-
*
|
|
23
|
-
* @fires data with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata
|
|
24
|
+
* @event `data` - Fired with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata
|
|
24
25
|
* has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}`
|
|
25
26
|
* to indicate that the source data has changed, so that any current caches should be flushed.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
* @property {number} maxzoom
|
|
29
|
-
* @property {boolean} isTileClipped `false` if tiles can be drawn outside their boundaries, `true` if they cannot.
|
|
30
|
-
* @property {boolean} reparseOverscaled `true` if tiles should be sent back to the worker for each overzoomed zoom
|
|
31
|
-
* level, `false` if not.
|
|
32
|
-
* @property {boolean} roundZoom `true` if zoom levels are rounded to the nearest integer in the source data, `false`
|
|
33
|
-
* if they are floor-ed to the nearest integer.
|
|
27
|
+
*
|
|
28
|
+
* @group Sources
|
|
34
29
|
*/
|
|
35
30
|
export interface Source {
|
|
36
31
|
readonly type: string;
|
|
32
|
+
/**
|
|
33
|
+
* The id for the source. Must not be used by any existing source.
|
|
34
|
+
*/
|
|
37
35
|
id: string;
|
|
38
36
|
minzoom: number;
|
|
39
37
|
maxzoom: number;
|
|
40
38
|
tileSize: number;
|
|
41
39
|
attribution?: string;
|
|
40
|
+
/**
|
|
41
|
+
* `true` if zoom levels are rounded to the nearest integer in the source data, `false` if they are floor-ed to the nearest integer.
|
|
42
|
+
*/
|
|
42
43
|
roundZoom?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* `false` if tiles can be drawn outside their boundaries, `true` if they cannot.
|
|
46
|
+
*/
|
|
43
47
|
isTileClipped?: boolean;
|
|
44
48
|
tileID?: CanonicalTileID;
|
|
49
|
+
/**
|
|
50
|
+
* `true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not.
|
|
51
|
+
*/
|
|
45
52
|
reparseOverscaled?: boolean;
|
|
46
53
|
vectorLayerIds?: Array<string>;
|
|
47
54
|
hasTransition(): boolean;
|
|
@@ -57,12 +64,14 @@ export interface Source {
|
|
|
57
64
|
* @returns A plain (stringifiable) JS object representing the current state of the source.
|
|
58
65
|
* Creating a source using the returned object as the `options` should result in a Source that is
|
|
59
66
|
* equivalent to this one.
|
|
60
|
-
* @private
|
|
61
67
|
*/
|
|
62
68
|
serialize(): any;
|
|
63
69
|
readonly prepare?: () => void;
|
|
64
70
|
}
|
|
65
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A supporting type to the source definition
|
|
74
|
+
*/
|
|
66
75
|
type SourceStatics = {
|
|
67
76
|
/*
|
|
68
77
|
* An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}
|
|
@@ -71,59 +80,58 @@ type SourceStatics = {
|
|
|
71
80
|
workerSourceURL?: URL;
|
|
72
81
|
};
|
|
73
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A general definition of a {@link Source} class for factory usage
|
|
85
|
+
*/
|
|
74
86
|
export type SourceClass = {
|
|
75
|
-
new (
|
|
87
|
+
new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source;
|
|
76
88
|
} & SourceStatics;
|
|
77
89
|
|
|
78
|
-
|
|
79
|
-
import raster from '../source/raster_tile_source';
|
|
80
|
-
import rasterDem from '../source/raster_dem_tile_source';
|
|
81
|
-
import geojson from '../source/geojson_source';
|
|
82
|
-
import video from '../source/video_source';
|
|
83
|
-
import image from '../source/image_source';
|
|
84
|
-
import canvas from '../source/canvas_source';
|
|
85
|
-
|
|
86
|
-
import type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
87
|
-
|
|
88
|
-
const sourceTypes = {
|
|
89
|
-
vector,
|
|
90
|
-
raster,
|
|
91
|
-
'raster-dem': rasterDem,
|
|
92
|
-
geojson,
|
|
93
|
-
video,
|
|
94
|
-
image,
|
|
95
|
-
canvas
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/*
|
|
90
|
+
/**
|
|
99
91
|
* Creates a tiled data source instance given an options object.
|
|
100
92
|
*
|
|
101
|
-
* @param id
|
|
102
|
-
* @param
|
|
93
|
+
* @param id - The id for the source. Must not be used by any existing source.
|
|
94
|
+
* @param specification - Source options, specific to the source type (except for `options.type`, which is always required).
|
|
95
|
+
* @param source - A source definition object compliant with
|
|
103
96
|
* [`maplibre-gl-style-spec`](https://maplibre.org/maplibre-style-spec/#sources) or, for a third-party source type,
|
|
104
97
|
* with that type's requirements.
|
|
105
|
-
* @param {Dispatcher}
|
|
106
|
-
* @returns
|
|
98
|
+
* @param dispatcher - A {@link Dispatcher} instance, which can be used to send messages to the workers.
|
|
99
|
+
* @returns a newly created source
|
|
107
100
|
*/
|
|
108
|
-
export const create =
|
|
109
|
-
|
|
101
|
+
export const create = (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source => {
|
|
102
|
+
|
|
103
|
+
const Class = getSourceType(specification.type);
|
|
104
|
+
const source = new Class(id, specification, dispatcher, eventedParent);
|
|
110
105
|
|
|
111
106
|
if (source.id !== id) {
|
|
112
107
|
throw new Error(`Expected Source id to be ${id} instead of ${source.id}`);
|
|
113
108
|
}
|
|
114
109
|
|
|
115
|
-
bindAll(['load', 'abort', 'unload', 'serialize', 'prepare'], source);
|
|
116
110
|
return source;
|
|
117
111
|
};
|
|
118
112
|
|
|
119
|
-
export const getSourceType =
|
|
120
|
-
|
|
113
|
+
export const getSourceType = (name: string): SourceClass => {
|
|
114
|
+
switch (name) {
|
|
115
|
+
case 'geojson':
|
|
116
|
+
return GeoJSONSource;
|
|
117
|
+
case 'image':
|
|
118
|
+
return ImageSource;
|
|
119
|
+
case 'raster':
|
|
120
|
+
return RasterTileSource;
|
|
121
|
+
case 'raster-dem':
|
|
122
|
+
return RasterDEMTileSource;
|
|
123
|
+
case 'vector':
|
|
124
|
+
return VectorTileSource;
|
|
125
|
+
case 'video':
|
|
126
|
+
return VideoSource;
|
|
127
|
+
case 'canvas':
|
|
128
|
+
return CanvasSource;
|
|
129
|
+
}
|
|
130
|
+
return registeredSources[name];
|
|
121
131
|
};
|
|
122
132
|
|
|
123
|
-
export const setSourceType =
|
|
124
|
-
|
|
125
|
-
}) {
|
|
126
|
-
sourceTypes[name] = type;
|
|
133
|
+
export const setSourceType = (name: string, type: SourceClass) => {
|
|
134
|
+
registeredSources[name] = type;
|
|
127
135
|
};
|
|
128
136
|
|
|
129
137
|
export interface Actor {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import SourceCache from './source_cache';
|
|
1
|
+
import {SourceCache} from './source_cache';
|
|
2
2
|
import {setSourceType} from './source';
|
|
3
|
-
import Tile from './tile';
|
|
3
|
+
import {Tile} from './tile';
|
|
4
4
|
import {OverscaledTileID} from './tile_id';
|
|
5
|
-
import Transform from '../geo/transform';
|
|
6
|
-
import LngLat from '../geo/lng_lat';
|
|
5
|
+
import {Transform} from '../geo/transform';
|
|
6
|
+
import {LngLat} from '../geo/lng_lat';
|
|
7
7
|
import Point from '@mapbox/point-geometry';
|
|
8
8
|
import {Event, ErrorEvent, Evented} from '../util/evented';
|
|
9
9
|
import {extend} from '../util/util';
|
|
10
|
-
import browser from '../util/browser';
|
|
11
|
-
import Dispatcher from '../util/dispatcher';
|
|
10
|
+
import {browser} from '../util/browser';
|
|
11
|
+
import {Dispatcher} from '../util/dispatcher';
|
|
12
12
|
import {Callback} from '../types/callback';
|
|
13
|
-
import TileBounds from './tile_bounds';
|
|
13
|
+
import {TileBounds} from './tile_bounds';
|
|
14
14
|
|
|
15
15
|
class SourceMock extends Evented {
|
|
16
16
|
id: string;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import {create as createSource} from './source';
|
|
2
2
|
|
|
3
|
-
import Tile from './tile';
|
|
3
|
+
import {Tile} from './tile';
|
|
4
4
|
import {Event, ErrorEvent, Evented} from '../util/evented';
|
|
5
|
-
import TileCache from './tile_cache';
|
|
6
|
-
import MercatorCoordinate from '../geo/mercator_coordinate';
|
|
5
|
+
import {TileCache} from './tile_cache';
|
|
6
|
+
import {MercatorCoordinate} from '../geo/mercator_coordinate';
|
|
7
7
|
import {keysDifference} from '../util/util';
|
|
8
|
-
import EXTENT from '../data/extent';
|
|
9
|
-
import Context from '../gl/context';
|
|
8
|
+
import {EXTENT} from '../data/extent';
|
|
9
|
+
import {Context} from '../gl/context';
|
|
10
10
|
import Point from '@mapbox/point-geometry';
|
|
11
|
-
import browser from '../util/browser';
|
|
11
|
+
import {browser} from '../util/browser';
|
|
12
12
|
import {OverscaledTileID} from './tile_id';
|
|
13
|
-
import SourceFeatureState from './source_state';
|
|
13
|
+
import {SourceFeatureState} from './source_state';
|
|
14
14
|
|
|
15
15
|
import type {Source} from './source';
|
|
16
|
-
import type Map from '../ui/map';
|
|
17
|
-
import type Style from '../style/style';
|
|
18
|
-
import type Dispatcher from '../util/dispatcher';
|
|
19
|
-
import type Transform from '../geo/transform';
|
|
16
|
+
import type {Map} from '../ui/map';
|
|
17
|
+
import type {Style} from '../style/style';
|
|
18
|
+
import type {Dispatcher} from '../util/dispatcher';
|
|
19
|
+
import type {Transform} from '../geo/transform';
|
|
20
20
|
import type {TileState} from './tile';
|
|
21
21
|
import type {Callback} from '../types/callback';
|
|
22
22
|
import type {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
23
23
|
import type {MapSourceDataEvent} from '../ui/events';
|
|
24
|
-
import Terrain from '../render/terrain';
|
|
25
|
-
import config from '../util/config';
|
|
24
|
+
import {Terrain} from '../render/terrain';
|
|
25
|
+
import {config} from '../util/config';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* `SourceCache` is responsible for
|
|
@@ -32,10 +32,8 @@ import config from '../util/config';
|
|
|
32
32
|
* - caching tiles loaded from an instance of `Source`
|
|
33
33
|
* - loading the tiles needed to render a given viewport
|
|
34
34
|
* - unloading the cached tiles not needed to render a given viewport
|
|
35
|
-
*
|
|
36
|
-
* @private
|
|
37
35
|
*/
|
|
38
|
-
class SourceCache extends Evented {
|
|
36
|
+
export class SourceCache extends Evented {
|
|
39
37
|
id: string;
|
|
40
38
|
dispatcher: Dispatcher;
|
|
41
39
|
map: Map;
|
|
@@ -138,7 +136,6 @@ class SourceCache extends Evented {
|
|
|
138
136
|
/**
|
|
139
137
|
* Return true if no tile data is pending, tiles will not change unless
|
|
140
138
|
* an additional API call is received.
|
|
141
|
-
* @private
|
|
142
139
|
*/
|
|
143
140
|
loaded(): boolean {
|
|
144
141
|
if (this._sourceErrored) { return true; }
|
|
@@ -208,7 +205,6 @@ class SourceCache extends Evented {
|
|
|
208
205
|
|
|
209
206
|
/**
|
|
210
207
|
* Return all tile ids ordered with z-order, and cast to numbers
|
|
211
|
-
* @private
|
|
212
208
|
*/
|
|
213
209
|
getIds(): Array<string> {
|
|
214
210
|
return (Object.values(this._tiles) as any).map((tile: Tile) => tile.tileID).sort(compareTileId).map(id => id.key);
|
|
@@ -298,7 +294,6 @@ class SourceCache extends Evented {
|
|
|
298
294
|
|
|
299
295
|
/**
|
|
300
296
|
* For raster terrain source, backfill DEM to eliminate visible tile boundaries
|
|
301
|
-
* @private
|
|
302
297
|
*/
|
|
303
298
|
_backfillDEM(tile: Tile) {
|
|
304
299
|
const renderables = this.getRenderableIds();
|
|
@@ -339,7 +334,6 @@ class SourceCache extends Evented {
|
|
|
339
334
|
}
|
|
340
335
|
/**
|
|
341
336
|
* Get a specific tile by TileID
|
|
342
|
-
* @private
|
|
343
337
|
*/
|
|
344
338
|
getTile(tileID: OverscaledTileID): Tile {
|
|
345
339
|
return this.getTileByID(tileID.key);
|
|
@@ -347,7 +341,6 @@ class SourceCache extends Evented {
|
|
|
347
341
|
|
|
348
342
|
/**
|
|
349
343
|
* Get a specific tile by id
|
|
350
|
-
* @private
|
|
351
344
|
*/
|
|
352
345
|
getTileByID(id: string): Tile {
|
|
353
346
|
return this._tiles[id];
|
|
@@ -356,7 +349,6 @@ class SourceCache extends Evented {
|
|
|
356
349
|
/**
|
|
357
350
|
* For a given set of tiles, retain children that are loaded and have a zoom
|
|
358
351
|
* between `zoom` (exclusive) and `maxCoveringZoom` (inclusive)
|
|
359
|
-
* @private
|
|
360
352
|
*/
|
|
361
353
|
_retainLoadedChildren(
|
|
362
354
|
idealTiles: {
|
|
@@ -406,7 +398,6 @@ class SourceCache extends Evented {
|
|
|
406
398
|
|
|
407
399
|
/**
|
|
408
400
|
* Find a loaded parent of the given tile (up to minCoveringZoom)
|
|
409
|
-
* @private
|
|
410
401
|
*/
|
|
411
402
|
findLoadedParent(tileID: OverscaledTileID, minCoveringZoom: number): Tile {
|
|
412
403
|
if (tileID.key in this._loadedParentTiles) {
|
|
@@ -443,7 +434,6 @@ class SourceCache extends Evented {
|
|
|
443
434
|
* Larger viewports use more tiles and need larger caches. Larger viewports
|
|
444
435
|
* are more likely to be found on devices with more memory and on pages where
|
|
445
436
|
* the map is more important.
|
|
446
|
-
* @private
|
|
447
437
|
*/
|
|
448
438
|
updateCacheSize(transform: Transform) {
|
|
449
439
|
const widthInTiles = Math.ceil(transform.width / this._source.tileSize) + 1;
|
|
@@ -504,7 +494,6 @@ class SourceCache extends Evented {
|
|
|
504
494
|
/**
|
|
505
495
|
* Removes tiles that are outside the viewport and adds new tiles that
|
|
506
496
|
* are inside the viewport.
|
|
507
|
-
* @private
|
|
508
497
|
*/
|
|
509
498
|
update(transform: Transform, terrain?: Terrain) {
|
|
510
499
|
this.transform = transform;
|
|
@@ -801,7 +790,6 @@ class SourceCache extends Evented {
|
|
|
801
790
|
|
|
802
791
|
/**
|
|
803
792
|
* Add a tile, given its coordinate, to the pyramid.
|
|
804
|
-
* @private
|
|
805
793
|
*/
|
|
806
794
|
_addTile(tileID: OverscaledTileID): Tile {
|
|
807
795
|
let tile = this._tiles[tileID.key];
|
|
@@ -854,7 +842,6 @@ class SourceCache extends Evented {
|
|
|
854
842
|
|
|
855
843
|
/**
|
|
856
844
|
* Remove a tile, given its id, from the pyramid
|
|
857
|
-
* @private
|
|
858
845
|
*/
|
|
859
846
|
_removeTile(id: string) {
|
|
860
847
|
const tile = this._tiles[id];
|
|
@@ -896,11 +883,10 @@ class SourceCache extends Evented {
|
|
|
896
883
|
/**
|
|
897
884
|
* Search through our current tiles and attempt to find the tiles that
|
|
898
885
|
* cover the given bounds.
|
|
899
|
-
* @param pointQueryGeometry coordinates of the corners of bounding rectangle
|
|
900
|
-
* @returns
|
|
901
|
-
* @private
|
|
886
|
+
* @param pointQueryGeometry - coordinates of the corners of bounding rectangle
|
|
887
|
+
* @returns 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.
|
|
902
888
|
*/
|
|
903
|
-
tilesIn(pointQueryGeometry: Array<Point>, maxPitchScaleFactor: number, has3DLayer: boolean) {
|
|
889
|
+
tilesIn(pointQueryGeometry: Array<Point>, maxPitchScaleFactor: number, has3DLayer: boolean): any[] {
|
|
904
890
|
|
|
905
891
|
const tileResults = [];
|
|
906
892
|
|
|
@@ -990,7 +976,6 @@ class SourceCache extends Evented {
|
|
|
990
976
|
|
|
991
977
|
/**
|
|
992
978
|
* Set the value of a particular state for a feature
|
|
993
|
-
* @private
|
|
994
979
|
*/
|
|
995
980
|
setFeatureState(sourceLayer: string, featureId: number | string, state: any) {
|
|
996
981
|
sourceLayer = sourceLayer || '_geojsonTileLayer';
|
|
@@ -999,7 +984,6 @@ class SourceCache extends Evented {
|
|
|
999
984
|
|
|
1000
985
|
/**
|
|
1001
986
|
* Resets the value of a particular state key for a feature
|
|
1002
|
-
* @private
|
|
1003
987
|
*/
|
|
1004
988
|
removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {
|
|
1005
989
|
sourceLayer = sourceLayer || '_geojsonTileLayer';
|
|
@@ -1008,7 +992,6 @@ class SourceCache extends Evented {
|
|
|
1008
992
|
|
|
1009
993
|
/**
|
|
1010
994
|
* Get the entire state object for a feature
|
|
1011
|
-
* @private
|
|
1012
995
|
*/
|
|
1013
996
|
getFeatureState(sourceLayer: string, featureId: number | string) {
|
|
1014
997
|
sourceLayer = sourceLayer || '_geojsonTileLayer';
|
|
@@ -1018,7 +1001,6 @@ class SourceCache extends Evented {
|
|
|
1018
1001
|
/**
|
|
1019
1002
|
* Sets the set of keys that the tile depends on. This allows tiles to
|
|
1020
1003
|
* be reloaded when their dependencies change.
|
|
1021
|
-
* @private
|
|
1022
1004
|
*/
|
|
1023
1005
|
setDependencies(tileKey: string, namespace: string, dependencies: Array<string>) {
|
|
1024
1006
|
const tile = this._tiles[tileKey];
|
|
@@ -1029,7 +1011,6 @@ class SourceCache extends Evented {
|
|
|
1029
1011
|
|
|
1030
1012
|
/**
|
|
1031
1013
|
* Reloads all tiles that depend on the given keys.
|
|
1032
|
-
* @private
|
|
1033
1014
|
*/
|
|
1034
1015
|
reloadTilesForDependencies(namespaces: Array<string>, keys: Array<string>) {
|
|
1035
1016
|
for (const id in this._tiles) {
|
|
@@ -1057,5 +1038,3 @@ function compareTileId(a: OverscaledTileID, b: OverscaledTileID): number {
|
|
|
1057
1038
|
function isRasterType(type) {
|
|
1058
1039
|
return type === 'raster' || type === 'image' || type === 'video';
|
|
1059
1040
|
}
|
|
1060
|
-
|
|
1061
|
-
export default SourceCache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {extend} from '../util/util';
|
|
2
|
-
import Tile from './tile';
|
|
2
|
+
import {Tile} from './tile';
|
|
3
3
|
import type {FeatureState} from '@maplibre/maplibre-gl-style-spec';
|
|
4
4
|
|
|
5
5
|
export type FeatureStates = {[featureId: string]: FeatureState};
|
|
@@ -12,9 +12,8 @@ export type LayerFeatureStates = {[layer: string]: FeatureStates};
|
|
|
12
12
|
* between coalesce() events. addFeatureState() and removeFeatureState() also update their counterpart's
|
|
13
13
|
* list of changes, such that coalesce() can apply the proper state changes while agnostic to the order of operations.
|
|
14
14
|
* In deletedStates, all null's denote complete removal of state at that scope
|
|
15
|
-
* @private
|
|
16
15
|
*/
|
|
17
|
-
class SourceFeatureState {
|
|
16
|
+
export class SourceFeatureState {
|
|
18
17
|
state: LayerFeatureStates;
|
|
19
18
|
stateChanges: LayerFeatureStates;
|
|
20
19
|
deletedStates: {};
|
|
@@ -155,5 +154,3 @@ class SourceFeatureState {
|
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
|
-
|
|
159
|
-
export default SourceFeatureState;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import TerrainSourceCache from './terrain_source_cache';
|
|
2
|
-
import Style from '../style/style';
|
|
1
|
+
import {TerrainSourceCache} from './terrain_source_cache';
|
|
2
|
+
import {Style} from '../style/style';
|
|
3
3
|
import {RequestManager} from '../util/request_manager';
|
|
4
|
-
import Dispatcher from '../util/dispatcher';
|
|
4
|
+
import {Dispatcher} from '../util/dispatcher';
|
|
5
5
|
import {fakeServer, FakeServer} from 'nise';
|
|
6
|
-
import Transform from '../geo/transform';
|
|
6
|
+
import {Transform} from '../geo/transform';
|
|
7
7
|
import {Evented} from '../util/evented';
|
|
8
|
-
import Painter from '../render/painter';
|
|
9
|
-
import RasterDEMTileSource from './raster_dem_tile_source';
|
|
8
|
+
import {Painter} from '../render/painter';
|
|
9
|
+
import {RasterDEMTileSource} from './raster_dem_tile_source';
|
|
10
10
|
import {OverscaledTileID} from './tile_id';
|
|
11
|
-
import Tile from './tile';
|
|
12
|
-
import DEMData from '../data/dem_data';
|
|
11
|
+
import {Tile} from './tile';
|
|
12
|
+
import {DEMData} from '../data/dem_data';
|
|
13
13
|
|
|
14
14
|
const transform = new Transform();
|
|
15
15
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {OverscaledTileID} from './tile_id';
|
|
2
|
-
import Tile from './tile';
|
|
3
|
-
import EXTENT from '../data/extent';
|
|
2
|
+
import {Tile} from './tile';
|
|
3
|
+
import {EXTENT} from '../data/extent';
|
|
4
4
|
import {mat4} from 'gl-matrix';
|
|
5
5
|
import {Evented} from '../util/evented';
|
|
6
|
-
import type Transform from '../geo/transform';
|
|
7
|
-
import type SourceCache from '../source/source_cache';
|
|
8
|
-
import Terrain from '../render/terrain';
|
|
6
|
+
import type {Transform} from '../geo/transform';
|
|
7
|
+
import type {SourceCache} from '../source/source_cache';
|
|
8
|
+
import {Terrain} from '../render/terrain';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This class is a helper for the Terrain-class, it:
|
|
@@ -15,23 +15,38 @@ import Terrain from '../render/terrain';
|
|
|
15
15
|
* - finds all necessary renderToTexture tiles for a OverscaledTileID area
|
|
16
16
|
* - finds the corresponding raster-dem tile for OverscaledTileID
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export class TerrainSourceCache extends Evented {
|
|
19
|
+
/**
|
|
20
|
+
* source-cache for the raster-dem source.
|
|
21
|
+
*/
|
|
21
22
|
sourceCache: SourceCache;
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* stores all render-to-texture tiles.
|
|
25
|
+
*/
|
|
23
26
|
_tiles: {[_: string]: Tile};
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* contains a list of tileID-keys for the current scene. (only for performance)
|
|
29
|
+
*/
|
|
25
30
|
_renderableTilesKeys: Array<string>;
|
|
26
|
-
|
|
31
|
+
/**
|
|
32
|
+
* raster-dem-tile for a TileID cache.
|
|
33
|
+
*/
|
|
27
34
|
_sourceTileCache: {[_: string]: string};
|
|
28
|
-
|
|
35
|
+
/**
|
|
36
|
+
* minimum zoomlevel to render the terrain.
|
|
37
|
+
*/
|
|
29
38
|
minzoom: number;
|
|
30
|
-
|
|
39
|
+
/**
|
|
40
|
+
* maximum zoomlevel to render the terrain.
|
|
41
|
+
*/
|
|
31
42
|
maxzoom: number;
|
|
32
|
-
|
|
43
|
+
/**
|
|
44
|
+
* render-to-texture tileSize in scene.
|
|
45
|
+
*/
|
|
33
46
|
tileSize: number;
|
|
34
|
-
|
|
47
|
+
/**
|
|
48
|
+
* raster-dem tiles will load for performance the actualZoom - deltaZoom zoom-level.
|
|
49
|
+
*/
|
|
35
50
|
deltaZoom: number;
|
|
36
51
|
|
|
37
52
|
constructor(sourceCache: SourceCache) {
|
|
@@ -55,8 +70,8 @@ export default class TerrainSourceCache extends Evented {
|
|
|
55
70
|
|
|
56
71
|
/**
|
|
57
72
|
* Load Terrain Tiles, create internal render-to-texture tiles, free GPU memory.
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
73
|
+
* @param transform - the operation to do
|
|
74
|
+
* @param terrain - the terrain
|
|
60
75
|
*/
|
|
61
76
|
update(transform: Transform, terrain: Terrain): void {
|
|
62
77
|
// load raster-dem tiles for the current scene.
|
|
@@ -87,7 +102,7 @@ export default class TerrainSourceCache extends Evented {
|
|
|
87
102
|
|
|
88
103
|
/**
|
|
89
104
|
* Free render to texture cache
|
|
90
|
-
* @param
|
|
105
|
+
* @param tileID - optional, free only corresponding to tileID.
|
|
91
106
|
*/
|
|
92
107
|
freeRtt(tileID?: OverscaledTileID) {
|
|
93
108
|
for (const key in this._tiles) {
|
|
@@ -99,7 +114,7 @@ export default class TerrainSourceCache extends Evented {
|
|
|
99
114
|
|
|
100
115
|
/**
|
|
101
116
|
* get a list of tiles, which are loaded and should be rendered in the current scene
|
|
102
|
-
* @returns
|
|
117
|
+
* @returns the renderable tiles
|
|
103
118
|
*/
|
|
104
119
|
getRenderableTiles(): Array<Tile> {
|
|
105
120
|
return this._renderableTilesKeys.map(key => this.getTileByID(key));
|
|
@@ -108,7 +123,7 @@ export default class TerrainSourceCache extends Evented {
|
|
|
108
123
|
/**
|
|
109
124
|
* get terrain tile by the TileID key
|
|
110
125
|
* @param id - the tile id
|
|
111
|
-
* @returns
|
|
126
|
+
* @returns the tile
|
|
112
127
|
*/
|
|
113
128
|
getTileByID(id: string): Tile {
|
|
114
129
|
return this._tiles[id];
|
|
@@ -116,8 +131,8 @@ export default class TerrainSourceCache extends Evented {
|
|
|
116
131
|
|
|
117
132
|
/**
|
|
118
133
|
* Searches for the corresponding current renderable terrain-tiles
|
|
119
|
-
* @param
|
|
120
|
-
* @returns
|
|
134
|
+
* @param tileID - the tile to look for
|
|
135
|
+
* @returns the tiles that were found
|
|
121
136
|
*/
|
|
122
137
|
getTerrainCoords(tileID: OverscaledTileID): Record<string, OverscaledTileID> {
|
|
123
138
|
const coords = {};
|
|
@@ -156,9 +171,9 @@ export default class TerrainSourceCache extends Evented {
|
|
|
156
171
|
|
|
157
172
|
/**
|
|
158
173
|
* find the covering raster-dem tile
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
161
|
-
* @returns
|
|
174
|
+
* @param tileID - the tile to look for
|
|
175
|
+
* @param searchForDEM - Optinal parameter to search for (parent) souretiles with loaded dem.
|
|
176
|
+
* @returns the tile
|
|
162
177
|
*/
|
|
163
178
|
getSourceTile(tileID: OverscaledTileID, searchForDEM?: boolean): Tile {
|
|
164
179
|
const source = this.sourceCache._source;
|
|
@@ -178,8 +193,8 @@ export default class TerrainSourceCache extends Evented {
|
|
|
178
193
|
|
|
179
194
|
/**
|
|
180
195
|
* get a list of tiles, loaded after a spezific time. This is used to update depth & coords framebuffers.
|
|
181
|
-
* @param
|
|
182
|
-
* @returns
|
|
196
|
+
* @param time - the time
|
|
197
|
+
* @returns the relevant tiles
|
|
183
198
|
*/
|
|
184
199
|
tilesAfterTime(time = Date.now()): Array<Tile> {
|
|
185
200
|
return Object.values(this._tiles).filter(t => t.timeAdded >= time);
|
package/src/source/tile.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {createSymbolBucket} from '../../test/unit/lib/create_symbol_layer';
|
|
2
|
-
import Tile from '../source/tile';
|
|
3
|
-
import GeoJSONWrapper,
|
|
2
|
+
import {Tile} from '../source/tile';
|
|
3
|
+
import {GeoJSONWrapper, Feature} from '../source/geojson_wrapper';
|
|
4
4
|
import {OverscaledTileID} from '../source/tile_id';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import vtpbf from 'vt-pbf';
|
|
8
|
-
import FeatureIndex from '../data/feature_index';
|
|
8
|
+
import {FeatureIndex} from '../data/feature_index';
|
|
9
9
|
import {CollisionBoxArray} from '../data/array_types.g';
|
|
10
10
|
import {extend} from '../util/util';
|
|
11
11
|
import {serialize, deserialize} from '../util/web_worker_transfer';
|