maplibre-gl 3.2.0 → 3.2.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.
Files changed (88) hide show
  1. package/build/generate-docs.ts +1 -1
  2. package/build/generate-struct-arrays.ts +3 -2
  3. package/dist/maplibre-gl-csp-worker.js +1 -1
  4. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  5. package/dist/maplibre-gl-csp.js +1 -1
  6. package/dist/maplibre-gl-csp.js.map +1 -1
  7. package/dist/maplibre-gl-dev.js +351 -281
  8. package/dist/maplibre-gl-dev.js.map +1 -1
  9. package/dist/maplibre-gl.d.ts +254 -181
  10. package/dist/maplibre-gl.js +4 -4
  11. package/dist/maplibre-gl.js.map +1 -1
  12. package/package.json +30 -30
  13. package/src/data/array_types.g.ts +32 -10
  14. package/src/data/bucket/circle_bucket.ts +1 -0
  15. package/src/data/bucket/line_bucket.ts +1 -0
  16. package/src/data/bucket/symbol_bucket.ts +1 -0
  17. package/src/data/feature_index.ts +1 -0
  18. package/src/data/program_configuration.ts +1 -0
  19. package/src/data/segment.ts +2 -0
  20. package/src/geo/transform.test.ts +9 -16
  21. package/src/geo/transform.ts +11 -32
  22. package/src/gl/context.ts +1 -0
  23. package/src/gl/framebuffer.ts +1 -0
  24. package/src/gl/index_buffer.ts +1 -0
  25. package/src/gl/render_pool.ts +2 -1
  26. package/src/gl/vertex_buffer.ts +1 -0
  27. package/src/render/draw_fill.test.ts +1 -1
  28. package/src/render/draw_symbol.test.ts +3 -3
  29. package/src/render/image_atlas.ts +1 -0
  30. package/src/render/line_atlas.ts +1 -0
  31. package/src/render/painter.ts +1 -1
  32. package/src/render/program.ts +1 -1
  33. package/src/render/render_to_texture.ts +31 -14
  34. package/src/render/terrain.test.ts +17 -0
  35. package/src/render/terrain.ts +34 -2
  36. package/src/render/texture.ts +1 -0
  37. package/src/render/uniform_binding.ts +2 -0
  38. package/src/render/vertex_array_object.ts +1 -0
  39. package/src/shaders/symbol_sdf.fragment.glsl +9 -3
  40. package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
  41. package/src/source/canvas_source.ts +1 -3
  42. package/src/source/geojson_source.ts +1 -3
  43. package/src/source/image_source.ts +2 -4
  44. package/src/source/raster_dem_tile_source.test.ts +14 -0
  45. package/src/source/raster_dem_tile_source.ts +0 -11
  46. package/src/source/raster_tile_source.test.ts +13 -0
  47. package/src/source/source_cache.ts +1 -0
  48. package/src/source/source_state.ts +1 -0
  49. package/src/source/terrain_source_cache.ts +1 -0
  50. package/src/source/tile.ts +1 -0
  51. package/src/source/tile_cache.ts +1 -1
  52. package/src/source/tile_id.ts +1 -0
  53. package/src/source/vector_tile_worker_source.test.ts +116 -67
  54. package/src/source/vector_tile_worker_source.ts +30 -16
  55. package/src/source/worker_source.ts +1 -0
  56. package/src/source/worker_tile.test.ts +143 -0
  57. package/src/source/worker_tile.ts +26 -7
  58. package/src/style/evaluation_parameters.ts +1 -0
  59. package/src/style/properties.ts +14 -0
  60. package/src/style/style.ts +1 -0
  61. package/src/style/style_glyph.ts +1 -0
  62. package/src/symbol/collision_index.ts +1 -0
  63. package/src/symbol/grid_index.ts +1 -0
  64. package/src/ui/camera.test.ts +12 -9
  65. package/src/ui/camera.ts +77 -95
  66. package/src/ui/handler/box_zoom.ts +1 -3
  67. package/src/ui/handler/click_zoom.ts +1 -3
  68. package/src/ui/handler/keyboard.ts +1 -3
  69. package/src/ui/handler/scroll_zoom.ts +1 -3
  70. package/src/ui/handler/shim/dblclick_zoom.ts +1 -3
  71. package/src/ui/handler/shim/drag_pan.ts +1 -3
  72. package/src/ui/handler/shim/drag_rotate.ts +1 -3
  73. package/src/ui/handler/shim/two_fingers_touch.ts +1 -3
  74. package/src/ui/handler/transform-provider.ts +1 -0
  75. package/src/ui/handler/two_fingers_touch.ts +1 -3
  76. package/src/ui/handler_manager.ts +2 -2
  77. package/src/ui/hash.ts +1 -2
  78. package/src/ui/map.test.ts +17 -12
  79. package/src/ui/map.ts +132 -44
  80. package/src/ui/map_events.test.ts +76 -0
  81. package/src/ui/marker.test.ts +1 -1
  82. package/src/util/ajax.test.ts +33 -0
  83. package/src/util/ajax.ts +5 -0
  84. package/src/util/image.ts +1 -0
  85. package/src/util/image_request.ts +2 -2
  86. package/src/util/performance.ts +1 -2
  87. package/src/util/struct_array.ts +5 -1
  88. package/src/util/test/mock_fetch.ts +51 -0
@@ -62,7 +62,7 @@ describe('drawSymbol', () => {
62
62
 
63
63
  const tileId = new OverscaledTileID(1, 0, 1, 0, 0);
64
64
  tileId.posMatrix = mat4.create();
65
- const programMock = new Program(null, null, null, null, null, null, null);
65
+ const programMock = new Program(null, null, null, null, null, null);
66
66
  (painterMock.useProgram as jest.Mock).mockReturnValue(programMock);
67
67
  const bucketMock = new SymbolBucket(null);
68
68
  bucketMock.icon = {
@@ -124,7 +124,7 @@ describe('drawSymbol', () => {
124
124
 
125
125
  const tileId = new OverscaledTileID(1, 0, 1, 0, 0);
126
126
  tileId.posMatrix = mat4.create();
127
- const programMock = new Program(null, null, null, null, null, null, null);
127
+ const programMock = new Program(null, null, null, null, null, null);
128
128
  (painterMock.useProgram as jest.Mock).mockReturnValue(programMock);
129
129
  const bucketMock = new SymbolBucket(null);
130
130
  bucketMock.icon = {
@@ -189,7 +189,7 @@ describe('drawSymbol', () => {
189
189
 
190
190
  const tileId = new OverscaledTileID(1, 0, 1, 0, 0);
191
191
  tileId.posMatrix = mat4.create();
192
- const programMock = new Program(null, null, null, null, null, null, null);
192
+ const programMock = new Program(null, null, null, null, null, null);
193
193
  (painterMock.useProgram as jest.Mock).mockReturnValue(programMock);
194
194
  const bucketMock = new SymbolBucket(null);
195
195
  bucketMock.icon = {
@@ -61,6 +61,7 @@ export class ImagePosition {
61
61
  }
62
62
 
63
63
  /**
64
+ * @internal
64
65
  * A class holding all the images
65
66
  */
66
67
  export class ImageAtlas {
@@ -12,6 +12,7 @@ type DashEntry = {
12
12
  }
13
13
 
14
14
  /**
15
+ * @internal
15
16
  * A LineAtlas lets us reuse rendered dashed lines
16
17
  * by writing many of them to a texture and then fetching their positions
17
18
  * using {@link LineAtlas#getDash}.
@@ -61,6 +61,7 @@ type PainterOptions = {
61
61
  };
62
62
 
63
63
  /**
64
+ * @internal
64
65
  * Initialize a new painter object.
65
66
  */
66
67
  export class Painter {
@@ -574,7 +575,6 @@ export class Painter {
574
575
  if (!this.cache[key]) {
575
576
  this.cache[key] = new Program(
576
577
  this.context,
577
- name,
578
578
  shaders[name],
579
579
  programConfiguration,
580
580
  programUniforms[name],
@@ -30,6 +30,7 @@ function getTokenizedAttributesAndUniforms(array: Array<string>): Array<string>
30
30
  }
31
31
 
32
32
  /**
33
+ * @internal
33
34
  * A webgl program to execute in the GPU space
34
35
  */
35
36
  export class Program<Us extends UniformBindings> {
@@ -42,7 +43,6 @@ export class Program<Us extends UniformBindings> {
42
43
  failedToCreate: boolean;
43
44
 
44
45
  constructor(context: Context,
45
- name: string,
46
46
  source: {
47
47
  fragmentSource: string;
48
48
  vertexSource: string;
@@ -9,7 +9,9 @@ import {RenderPool} from '../gl/render_pool';
9
9
  import {Texture} from './texture';
10
10
  import type {StyleLayer} from '../style/style_layer';
11
11
 
12
- // lookup table which layers should rendered to texture
12
+ /**
13
+ * lookup table which layers should rendered to texture
14
+ */
13
15
  const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {
14
16
  background: true,
15
17
  fill: true,
@@ -19,30 +21,45 @@ const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {
19
21
  };
20
22
 
21
23
  /**
22
- * RenderToTexture
24
+ * @internal
25
+ * A helper class to help define what should be rendered to texture and how
23
26
  */
24
27
  export class RenderToTexture {
25
28
  painter: Painter;
26
29
  terrain: Terrain;
27
30
  pool: RenderPool;
28
- // coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile
29
- // e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile
31
+ /**
32
+ * coordsDescendingInv contains a list of all tiles which should be rendered for one render-to-texture tile
33
+ * e.g. render 4 raster-tiles with size 256px to the 512px render-to-texture tile
34
+ */
30
35
  _coordsDescendingInv: {[_: string]: {[_:string]: Array<OverscaledTileID>}};
31
- // create a string representation of all to tiles rendered to render-to-texture tiles
32
- // this string representation is used to check if tile should be re-rendered.
36
+ /**
37
+ * create a string representation of all to tiles rendered to render-to-texture tiles
38
+ * this string representation is used to check if tile should be re-rendered.
39
+ */
33
40
  _coordsDescendingInvStr: {[_: string]: {[_:string]: string}};
34
- // store for render-stacks
35
- // a render stack is a set of layers which should be rendered into one texture
36
- // every stylesheet can have multiple stacks. A new stack is created if layers which should
37
- // not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols
41
+ /**
42
+ * store for render-stacks
43
+ * a render stack is a set of layers which should be rendered into one texture
44
+ * every stylesheet can have multiple stacks. A new stack is created if layers which should
45
+ * not rendered to texture sit inbetween layers which should rendered to texture. e.g. hillshading or symbols
46
+ */
38
47
  _stacks: Array<Array<string>>;
39
- // remember the previous processed layer to check if a new stack is needed
48
+ /**
49
+ * remember the previous processed layer to check if a new stack is needed
50
+ */
40
51
  _prevType: string;
41
- // a list of tiles that can potentially rendered
52
+ /**
53
+ * a list of tiles that can potentially rendered
54
+ */
42
55
  _renderableTiles: Array<Tile>;
43
- // a list of tiles that should be rendered to screen in the next render-call
56
+ /**
57
+ * a list of tiles that should be rendered to screen in the next render-call
58
+ */
44
59
  _rttTiles: Array<Tile>;
45
- // a list of all layer-ids which should be rendered
60
+ /**
61
+ * a list of all layer-ids which should be rendered
62
+ */
46
63
  _renderableLayerIds: Array<string>;
47
64
 
48
65
  constructor(painter: Painter, terrain: Terrain) {
@@ -11,6 +11,7 @@ import type {DEMData} from '../data/dem_data';
11
11
  import {Tile} from '../source/tile';
12
12
  import {Painter} from './painter';
13
13
  import {mat4} from 'gl-matrix';
14
+ import {LngLat} from '../geo/lng_lat';
14
15
 
15
16
  describe('Terrain', () => {
16
17
  test('pointCoordiate should not return null', () => {
@@ -193,4 +194,20 @@ describe('Terrain', () => {
193
194
  expect(mockTerrain.getDEMElevation(null, 0.4, 0.2)).toBeCloseTo(42);
194
195
  });
195
196
 
197
+ test('getElevationForLngLatZoom with lng less than -180 wraps correctly', () => {
198
+ const terrain = new Terrain(null, {} as any, {} as any);
199
+
200
+ const OVERSCALETILEID_DOES_NOT_THROW = 4;
201
+ terrain.getElevation = () => OVERSCALETILEID_DOES_NOT_THROW;
202
+ expect(terrain.getElevationForLngLatZoom(new LngLat(-183, 40), 0)).toBe(OVERSCALETILEID_DOES_NOT_THROW);
203
+ });
204
+
205
+ test('getMinTileElevationForLngLatZoom with lng less than -180 wraps correctly', () => {
206
+ const terrain = new Terrain(null, {} as any, {} as any);
207
+
208
+ const OVERSCALETILEID_DOES_NOT_THROW = 4;
209
+ terrain.getMinMaxElevation = () => ({minElevation: OVERSCALETILEID_DOES_NOT_THROW, maxElevation: 42});
210
+ expect(terrain.getMinTileElevationForLngLatZoom(new LngLat(-183, 40), 0)).toBe(OVERSCALETILEID_DOES_NOT_THROW);
211
+ });
212
+
196
213
  });
@@ -18,9 +18,10 @@ import {TerrainSourceCache} from '../source/terrain_source_cache';
18
18
  import {SourceCache} from '../source/source_cache';
19
19
  import {EXTENT} from '../data/extent';
20
20
  import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';
21
- import {earthRadius} from '../geo/lng_lat';
21
+ import {LngLat, earthRadius} from '../geo/lng_lat';
22
22
 
23
23
  /**
24
+ * @internal
24
25
  * A terrain GPU related object
25
26
  */
26
27
  export type TerrainData = {
@@ -36,6 +37,7 @@ export type TerrainData = {
36
37
  }
37
38
 
38
39
  /**
40
+ * @internal
39
41
  * A terrain mesh object
40
42
  */
41
43
  export type TerrainMesh = {
@@ -45,6 +47,7 @@ export type TerrainMesh = {
45
47
  }
46
48
 
47
49
  /**
50
+ * @internal
48
51
  * This is the main class which handles most of the 3D Terrain logic. It has the following topics:
49
52
  * 1) loads raster-dem tiles via the internal sourceCache this.sourceCache
50
53
  * 2) creates a depth-framebuffer, which is used to calculate the visibility of coordinates
@@ -180,7 +183,18 @@ export class Terrain {
180
183
  }
181
184
 
182
185
  /**
183
- * get the Elevation for given coordinate in respect of exaggeration.
186
+ * Get the elevation for given {@link LngLat} in respect of exaggeration.
187
+ * @param lnglat - the location
188
+ * @param zoom - the zoom
189
+ * @returns the elevation
190
+ */
191
+ getElevationForLngLatZoom(lnglat: LngLat, zoom: number) {
192
+ const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);
193
+ return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT);
194
+ }
195
+
196
+ /**
197
+ * Get the elevation for given coordinate in respect of exaggeration.
184
198
  * @param tileID - the tile id
185
199
  * @param x - between 0 .. EXTENT
186
200
  * @param y - between 0 .. EXTENT
@@ -391,6 +405,11 @@ export class Terrain {
391
405
  return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5;
392
406
  }
393
407
 
408
+ getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) {
409
+ const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);
410
+ return this.getMinMaxElevation(tileID).minElevation ?? 0;
411
+ }
412
+
394
413
  /**
395
414
  * Get the minimum and maximum elevation contained in a tile. This includes any
396
415
  * exaggeration included in the terrain.
@@ -409,4 +428,17 @@ export class Terrain {
409
428
  return minMax;
410
429
  }
411
430
 
431
+ _getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} {
432
+ const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap());
433
+ const worldSize = (1 << zoom) * EXTENT;
434
+ const mercatorX = mercatorCoordinate.x * worldSize;
435
+ const mercatorY = mercatorCoordinate.y * worldSize;
436
+ const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);
437
+ const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY);
438
+ return {
439
+ tileID,
440
+ mercatorX,
441
+ mercatorY
442
+ };
443
+ }
412
444
  }
@@ -16,6 +16,7 @@ type DataTextureImage = RGBAImage | AlphaImage | EmptyImage;
16
16
  export type TextureImage = TexImageSource | DataTextureImage;
17
17
 
18
18
  /**
19
+ * @internal
19
20
  * A `Texture` GL related object
20
21
  */
21
22
  export class Texture {
@@ -11,6 +11,7 @@ export type UniformValues<Us extends {}> = $ObjMap<Us, <V>(u: Uniform<V>) => V>;
11
11
  export type UniformLocations = {[_: string]: WebGLUniformLocation};
12
12
 
13
13
  /**
14
+ * @internal
14
15
  * A base uniform abstract class
15
16
  */
16
17
  abstract class Uniform<T> {
@@ -150,6 +151,7 @@ export {
150
151
  };
151
152
 
152
153
  /**
154
+ * @internal
153
155
  * A uniform bindings
154
156
  */
155
157
  export type UniformBindings = {[_: string]: Uniform<any>};
@@ -5,6 +5,7 @@ import type {IndexBuffer} from '../gl/index_buffer';
5
5
  import type {Context} from '../gl/context';
6
6
 
7
7
  /**
8
+ * @internal
8
9
  * A vertex array object used to pass data to the webgl code
9
10
  */
10
11
  export class VertexArrayObject {
@@ -33,16 +33,22 @@ void main() {
33
33
 
34
34
  lowp vec4 color = fill_color;
35
35
  highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
36
- lowp float buff = (256.0 - 64.0) / 256.0;
36
+ lowp float inner_edge = (256.0 - 64.0) / 256.0;
37
37
  if (u_is_halo) {
38
38
  color = halo_color;
39
39
  gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
40
- buff = (6.0 - halo_width / fontScale) / SDF_PX;
40
+ inner_edge = inner_edge + gamma * gamma_scale;
41
41
  }
42
42
 
43
43
  lowp float dist = texture(u_texture, tex).a;
44
44
  highp float gamma_scaled = gamma * gamma_scale;
45
- highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
45
+ highp float alpha = smoothstep(inner_edge - gamma_scaled, inner_edge + gamma_scaled, dist);
46
+ if (u_is_halo) {
47
+ // When drawing halos, we want the inside of the halo to be transparent as well
48
+ // in case the text fill is transparent.
49
+ lowp float halo_edge = (6.0 - halo_width / fontScale) / SDF_PX;
50
+ alpha = min(smoothstep(halo_edge - gamma_scaled, halo_edge + gamma_scaled, dist), 1.0 - alpha);
51
+ }
46
52
 
47
53
  fragColor = color * (alpha * opacity * fade_opacity);
48
54
 
@@ -1,2 +1,2 @@
1
1
  // This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
2
- export default '#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
2
+ export default '#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
@@ -81,9 +81,7 @@ export class CanvasSource extends ImageSource {
81
81
  pause: () => void;
82
82
  _playing: boolean;
83
83
 
84
- /**
85
- * @hidden
86
- */
84
+ /** @internal */
87
85
  constructor(id: string, options: CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
88
86
  super(id, options, dispatcher, eventedParent);
89
87
 
@@ -138,9 +138,7 @@ export class GeoJSONSource extends Evented implements Source {
138
138
  _collectResourceTiming: boolean;
139
139
  _removed: boolean;
140
140
 
141
- /**
142
- * @hidden
143
- */
141
+ /** @internal */
144
142
  constructor(id: string, options: GeoJSONSourceOptions, dispatcher: Dispatcher, eventedParent: Evented) {
145
143
  super();
146
144
 
@@ -109,9 +109,7 @@ export class ImageSource extends Evented implements Source {
109
109
  _loaded: boolean;
110
110
  _request: Cancelable;
111
111
 
112
- /**
113
- * @hidden
114
- */
112
+ /** @internal */
115
113
  constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
116
114
  super();
117
115
  this.id = id;
@@ -317,7 +315,7 @@ export class ImageSource extends Evented implements Source {
317
315
  * Given a list of coordinates, get their center as a coordinate.
318
316
  *
319
317
  * @returns centerpoint
320
- * @hidden
318
+ * @internal
321
319
  */
322
320
  export function getCoordinatesCenterTileID(coords: Array<MercatorCoordinate>) {
323
321
  let minX = Infinity;
@@ -150,4 +150,18 @@ describe('RasterTileSource', () => {
150
150
  });
151
151
  server.respond();
152
152
  });
153
+
154
+ it('serializes options', () => {
155
+ const source = createSource({
156
+ tiles: ['http://localhost:2900/raster-dem/{z}/{x}/{y}.png'],
157
+ minzoom: 2,
158
+ maxzoom: 10
159
+ });
160
+ expect(source.serialize()).toStrictEqual({
161
+ type: 'raster-dem',
162
+ tiles: ['http://localhost:2900/raster-dem/{z}/{x}/{y}.png'],
163
+ minzoom: 2,
164
+ maxzoom: 10
165
+ });
166
+ });
153
167
  });
@@ -43,17 +43,6 @@ export class RasterDEMTileSource extends RasterTileSource implements Source {
43
43
  this.encoding = options.encoding || 'mapbox';
44
44
  }
45
45
 
46
- serialize() {
47
- return {
48
- type: 'raster-dem',
49
- url: this.url,
50
- tileSize: this.tileSize,
51
- tiles: this.tiles,
52
- bounds: this.bounds,
53
- encoding: this.encoding
54
- };
55
- }
56
-
57
46
  loadTile(tile: Tile, callback: Callback<void>) {
58
47
  const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
59
48
  tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), imageLoaded.bind(this), this.map._refreshExpiredTiles);
@@ -170,4 +170,17 @@ describe('RasterTileSource', () => {
170
170
  expect((server.requests.pop() as any).aborted).toBe(true);
171
171
  });
172
172
 
173
+ it('serializes options', () => {
174
+ const source = createSource({
175
+ tiles: ['http://localhost:2900/raster/{z}/{x}/{y}.png'],
176
+ minzoom: 2,
177
+ maxzoom: 10
178
+ });
179
+ expect(source.serialize()).toStrictEqual({
180
+ type: 'raster',
181
+ tiles: ['http://localhost:2900/raster/{z}/{x}/{y}.png'],
182
+ minzoom: 2,
183
+ maxzoom: 10
184
+ });
185
+ });
173
186
  });
@@ -25,6 +25,7 @@ import {Terrain} from '../render/terrain';
25
25
  import {config} from '../util/config';
26
26
 
27
27
  /**
28
+ * @internal
28
29
  * `SourceCache` is responsible for
29
30
  *
30
31
  * - creating an instance of `Source`
@@ -6,6 +6,7 @@ export type FeatureStates = {[featureId: string]: FeatureState};
6
6
  export type LayerFeatureStates = {[layer: string]: FeatureStates};
7
7
 
8
8
  /**
9
+ * @internal
9
10
  * SourceFeatureState manages the state and pending changes
10
11
  * to features in a source, separated by source layer.
11
12
  * stateChanges and deletedStates batch all changes to the tile (updates and removes, respectively)
@@ -8,6 +8,7 @@ import type {SourceCache} from '../source/source_cache';
8
8
  import {Terrain} from '../render/terrain';
9
9
 
10
10
  /**
11
+ * @internal
11
12
  * This class is a helper for the Terrain-class, it:
12
13
  * - loads raster-dem tiles
13
14
  * - manages all renderToTexture tiles.
@@ -47,6 +47,7 @@ import {ExpiryData} from '../util/ajax';
47
47
  export type TileState = 'loading' | 'loaded' | 'reloading' | 'unloaded' | 'errored' | 'expired';
48
48
 
49
49
  /**
50
+ * @internal
50
51
  * A tile object is the combination of a Coordinate, which defines
51
52
  * its place, as well as a unique ID and data tracking for its content
52
53
  */
@@ -2,10 +2,10 @@ import {OverscaledTileID} from './tile_id';
2
2
  import type {Tile} from './tile';
3
3
 
4
4
  /**
5
+ * @internal
5
6
  * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)
6
7
  * with hash lookup made possible by keeping a list of keys in parallel to
7
8
  * an array of dictionary of values
8
- *
9
9
  */
10
10
  export class TileCache {
11
11
  max: number;
@@ -64,6 +64,7 @@ export class CanonicalTileID implements ICanonicalTileID {
64
64
  }
65
65
 
66
66
  /**
67
+ * @internal
67
68
  * An unwrapped tile identifier
68
69
  */
69
70
  export class UnwrappedTileID {