@tangram.gl/basemap-layers 0.0.1 → 10.0.0-alpha.3

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 (139) hide show
  1. package/README.md +12 -7
  2. package/THIRD-PARTY-NOTICES.md +7 -5
  3. package/dist/geojson-task-worker.js +3166 -0
  4. package/dist/geojson-task-worker.js.map +6 -0
  5. package/dist/geojson-worker.js +1089 -7
  6. package/dist/geojson-worker.js.map +3 -3
  7. package/dist/index.cjs +9588 -2093
  8. package/dist/index.cjs.map +3 -3
  9. package/dist/index.js +9599 -2090
  10. package/dist/index.js.map +3 -3
  11. package/dist/map-style.cjs +456 -20
  12. package/dist/map-style.cjs.map +3 -3
  13. package/dist/map-style.js +456 -19
  14. package/dist/map-style.js.map +2 -2
  15. package/dist/types/basemap-error.d.ts +52 -0
  16. package/dist/types/basemap-layer.d.ts +378 -25
  17. package/dist/types/basemap-protocol.d.ts +91 -0
  18. package/dist/types/basemap-request.d.ts +73 -0
  19. package/dist/types/circle-layer.d.ts +65 -8
  20. package/dist/types/color-relief-layer.d.ts +184 -0
  21. package/dist/types/dem-pixels.d.ts +40 -0
  22. package/dist/types/feature-state.d.ts +55 -0
  23. package/dist/types/fill-extrusion-lighting-extension.d.ts +1 -2
  24. package/dist/types/fill-outline-extension.d.ts +2 -3
  25. package/dist/types/fill-pattern.d.ts +35 -3
  26. package/dist/types/fill-style-extensions.d.ts +11 -59
  27. package/dist/types/geojson-resource.d.ts +18 -0
  28. package/dist/types/geojson-source.d.ts +13 -2
  29. package/dist/types/geojson-task-handler.d.ts +2 -0
  30. package/dist/types/geojson-task.d.ts +26 -0
  31. package/dist/types/geojson-tiler.d.ts +29 -2
  32. package/dist/types/geojson-worker.d.ts +5 -1
  33. package/dist/types/globe-horizon-extension.d.ts +2 -45
  34. package/dist/types/globe-layers.d.ts +141 -45
  35. package/dist/types/globe-line-angle-extension.d.ts +20 -17
  36. package/dist/types/glyph-store.d.ts +10 -1
  37. package/dist/types/heatmap-layer.d.ts +99 -0
  38. package/dist/types/hillshade-layer.d.ts +159 -27
  39. package/dist/types/icon-text-fit.d.ts +92 -0
  40. package/dist/types/image-source-layer.d.ts +142 -0
  41. package/dist/types/index.d.ts +25 -1
  42. package/dist/types/line-blur-extension.d.ts +3 -11
  43. package/dist/types/line-dash-extension.d.ts +53 -0
  44. package/dist/types/line-gradient-extension.d.ts +69 -0
  45. package/dist/types/line-metrics.d.ts +24 -0
  46. package/dist/types/line-pattern-extension.d.ts +50 -0
  47. package/dist/types/line-shape-extension.d.ts +76 -0
  48. package/dist/types/map-style-loader.d.ts +1 -1
  49. package/dist/types/map-style.d.ts +2 -2
  50. package/dist/types/mvt-label-layer.d.ts +111 -20
  51. package/dist/types/pmtiles-source.d.ts +38 -0
  52. package/dist/types/projected-background-layer.d.ts +63 -0
  53. package/dist/types/projected-bitmap-layer.d.ts +58 -0
  54. package/dist/types/projected-tile-data.d.ts +16 -0
  55. package/dist/types/projected-tile-selection.d.ts +72 -0
  56. package/dist/types/projected-tileset.d.ts +92 -0
  57. package/dist/types/projected-viewport.d.ts +76 -0
  58. package/dist/types/raster-color-extension.d.ts +4 -7
  59. package/dist/types/raster-fade.d.ts +155 -0
  60. package/dist/types/raster-tile-fingerprint.d.ts +11 -0
  61. package/dist/types/raster-tile-loader.d.ts +80 -0
  62. package/dist/types/shader-injection-plugin.d.ts +8 -0
  63. package/dist/types/source-features.d.ts +58 -0
  64. package/dist/types/source-tiles.d.ts +32 -0
  65. package/dist/types/sprite.d.ts +37 -3
  66. package/dist/types/stretch-icon-layer.d.ts +28 -0
  67. package/dist/types/style-accessor.d.ts +50 -12
  68. package/dist/types/style-expression.d.ts +22 -2
  69. package/dist/types/style-resolver.d.ts +47 -2
  70. package/dist/types/terrain-query.d.ts +39 -0
  71. package/dist/types/zoom-load-gate.d.ts +22 -0
  72. package/dist/types/zoom-paint-extension.d.ts +80 -11
  73. package/package.json +24 -21
  74. package/src/basemap-error.ts +82 -0
  75. package/src/basemap-layer.ts +1289 -101
  76. package/src/basemap-protocol.ts +353 -0
  77. package/src/basemap-request.ts +212 -0
  78. package/src/circle-layer.ts +430 -54
  79. package/src/color-relief-layer.ts +572 -0
  80. package/src/dem-pixels.ts +174 -0
  81. package/src/feature-state.ts +164 -0
  82. package/src/fill-extrusion-lighting-extension.ts +126 -9
  83. package/src/fill-outline-extension.ts +4 -4
  84. package/src/fill-pattern.ts +87 -9
  85. package/src/fill-style-extensions.ts +114 -44
  86. package/src/geojson-resource.ts +58 -0
  87. package/src/geojson-source.ts +106 -85
  88. package/src/geojson-task-handler.ts +11 -0
  89. package/src/geojson-task-worker.ts +8 -0
  90. package/src/geojson-task.ts +34 -0
  91. package/src/geojson-tiler.ts +270 -4
  92. package/src/geojson-worker.ts +36 -6
  93. package/src/globe-horizon-extension.ts +14 -4
  94. package/src/globe-layers.ts +1905 -406
  95. package/src/globe-line-angle-extension.ts +183 -23
  96. package/src/glyph-store.ts +28 -6
  97. package/src/heatmap-layer.ts +591 -0
  98. package/src/hillshade-layer.ts +309 -88
  99. package/src/icon-text-fit.ts +358 -0
  100. package/src/image-source-layer.ts +380 -0
  101. package/src/index.ts +58 -1
  102. package/src/line-blur-extension.ts +14 -12
  103. package/src/line-dash-extension.ts +303 -0
  104. package/src/line-gradient-extension.ts +191 -0
  105. package/src/line-metrics.ts +90 -0
  106. package/src/line-pattern-extension.ts +173 -0
  107. package/src/line-shape-extension.ts +272 -0
  108. package/src/map-style-loader.ts +5 -4
  109. package/src/map-style.ts +2 -1
  110. package/src/mvt-label-layer.ts +568 -144
  111. package/src/pmtiles-source.ts +276 -0
  112. package/src/projected-background-layer.ts +202 -0
  113. package/src/projected-bitmap-layer.ts +262 -0
  114. package/src/projected-tile-data.ts +132 -0
  115. package/src/projected-tile-selection.ts +605 -0
  116. package/src/projected-tileset.ts +183 -0
  117. package/src/projected-viewport.ts +254 -0
  118. package/src/raster-color-extension.ts +43 -18
  119. package/src/raster-fade.ts +319 -0
  120. package/src/raster-tile-fingerprint.ts +31 -0
  121. package/src/raster-tile-loader.ts +211 -0
  122. package/src/shader-injection-plugin.ts +25 -0
  123. package/src/source-features.ts +170 -0
  124. package/src/source-tiles.ts +102 -0
  125. package/src/sprite.ts +122 -15
  126. package/src/stretch-icon-layer.ts +87 -0
  127. package/src/style-accessor.ts +105 -17
  128. package/src/style-expression.ts +80 -3
  129. package/src/style-resolver.ts +200 -22
  130. package/src/terrain-query.ts +86 -0
  131. package/src/text-layout.ts +2 -3
  132. package/src/zoom-load-gate.ts +57 -0
  133. package/src/zoom-paint-extension.ts +245 -47
  134. package/dist/types/arabic-shaping.d.ts +0 -7
  135. package/dist/types/bidi.d.ts +0 -8
  136. package/dist/types/polylabel.d.ts +0 -17
  137. package/src/arabic-shaping.ts +0 -366
  138. package/src/bidi.ts +0 -199
  139. package/src/polylabel.ts +0 -312
@@ -4,12 +4,13 @@ import { LabelPlacement, type PlacementLayer, type PlacementSymbol, type SymbolP
4
4
  import type { LabelTextJustify } from "./label-text-layer.js";
5
5
  import { SharedTextureSet } from "./shared-texture.js";
6
6
  import { type CompiledStyleProperty } from "./style-expression.js";
7
+ import type { FittedIcon, IconTextFit } from "./icon-text-fit.js";
7
8
  import type { ResolvedSpriteIcon, SpriteAtlas } from "./sprite.js";
8
9
  import { GlobeLineAngleExtension } from "./globe-line-angle-extension.js";
9
10
  import type { GlyphStore } from "./glyph-store.js";
10
11
  import { type LabelLine, type LineGlyphs } from "./line-glyphs.js";
11
12
  import type { WrapBudget } from "./text-layout.js";
12
- import { type PoleSearchBudget } from "./polylabel.js";
13
+ import { type PoleSearchBudget } from '@math.gl/geometry/polygon';
13
14
  import type { LabelFont, LabelFontFamily } from "./text-font.js";
14
15
  import { type LineAnchorBudget } from "./line-placement.js";
15
16
  type GeometryType = 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | string;
@@ -21,6 +22,16 @@ type FeatureLike = {
21
22
  geometry: FeatureGeometry;
22
23
  properties?: Record<string, any>;
23
24
  };
25
+ /**
26
+ * One quad of a label row's icon, fitted to its text (`part`), or the whole icon at its own size
27
+ * for a row without text (`part` null). It inherits the row's fields, such as `position` and
28
+ * `__source`, so accessors of rows read it as its row.
29
+ */
30
+ type FittedIconPiece = LabelRow & {
31
+ row: LabelRow;
32
+ rowIndex: number;
33
+ part: number | null;
34
+ };
24
35
  type LabelRow = {
25
36
  position: number[];
26
37
  /** For labels along a line: the line's direction, in degrees counter-clockwise from east. */
@@ -116,16 +127,21 @@ export type MVTLabelLayerProps = {
116
127
  east: number;
117
128
  north: number;
118
129
  } | null;
119
- /** The tile's zoom level, at which labels along lines are spaced. Default: the integer `zoom`. */
130
+ /** The tile's index zoom. Defaults to the integer map zoom adjusted for the tile size. */
120
131
  tileZoom?: number | null;
132
+ /**
133
+ * The source's deepest tile zoom (`maxzoom`), in tile-index zoom like `tileZoom`.
134
+ * Coarser tiles never overzoom.
135
+ */
136
+ tileMaxZoom?: number | null;
121
137
  /** The tile's size in pixels at its own zoom. Default: 512. */
122
138
  tileSize?: number | null;
123
139
  /**
124
140
  * The label features of several tiles, labelled together in one layer instead of `data`: each
125
- * tile's anchors are placed as for a layer of its own (`tileBoundingBox`, `tileZoom` and
126
- * `tileSize` per tile), then drawn in longitude/latitude. Pass the same array while the tiles do
127
- * not change; a tile keeps its anchors while its features, and the inputs they depend on, do not
128
- * change. See {@link LabelTile}.
141
+ * tile's anchors are placed as for a layer of its own, using its `tileBoundingBox`, `tileZoom`,
142
+ * `tileMaxZoom` and `tileSize`, then drawn in longitude/latitude. Pass the same array while
143
+ * the tiles stay the same. A tile keeps its anchors while its features and placement inputs
144
+ * stay the same. See {@link LabelTile}.
129
145
  */
130
146
  tiles?: LabelTile[] | null;
131
147
  };
@@ -146,6 +162,11 @@ export type LabelTile = {
146
162
  north: number;
147
163
  } | null;
148
164
  tileZoom?: number | null;
165
+ /**
166
+ * The source's deepest tile zoom (`maxzoom`), in tile-index zoom like `tileZoom`.
167
+ * Coarser tiles never overzoom.
168
+ */
169
+ tileMaxZoom?: number | null;
149
170
  tileSize?: number | null;
150
171
  /** Returned as `info.tile` when a label of the tile is picked. */
151
172
  tile?: unknown;
@@ -174,6 +195,14 @@ type TileRows = {
174
195
  * rows are in longitude/latitude; otherwise they are already converted, see `getTileRowsInWorld`.
175
196
  */
176
197
  export declare function combineTileRows(tiles: LabelTile[], tileRows: LabelRow[][]): LabelRow[];
198
+ /**
199
+ * The rows whose anchor lies on a tile of `tiles`. A tile of a low zoom holds labels of places far
200
+ * outside it, and a projected view draws only the tiles in the projection's area of use: an anchor
201
+ * on no drawn tile is off the drawn map. One on another drawn tile is kept, as a tile of a mixed
202
+ * selection may not hold the labels of its own area, which the buffer of a deeper tile does.
203
+ * Rows are in longitude/latitude.
204
+ */
205
+ export declare function filterRowsOnDrawnTiles(tiles: LabelTile[], rows: LabelRow[]): LabelRow[];
177
206
  /** What placement needs of a label layer's rows that does not change with the view. */
178
207
  type PlacementGeometry = {
179
208
  key: unknown[];
@@ -194,6 +223,17 @@ type PlacementGeometry = {
194
223
  positions: Float64Array;
195
224
  };
196
225
  };
226
+ /** One quad of an icon stretched by `icon-text-fit`, as a `StretchIconLayer` draws it. */
227
+ type FittedIconPart = {
228
+ /** The mapping entry of the quad's part of the image (see `getStretchIconMapping`). */
229
+ name: string;
230
+ /** Height in pixels. */
231
+ size: number;
232
+ /** `getIconStretch`: the width over the image part's aspect ratio at `size`. */
233
+ stretch: [number, number];
234
+ /** The quad's center in pixels from the anchor, before the icon turns. */
235
+ offset: [number, number];
236
+ };
197
237
  /** A label anchor with variable anchors: the anchor, and its offset in ems of `text-size`. */
198
238
  export type TextAnchorOffset = {
199
239
  anchor: string;
@@ -237,6 +277,17 @@ type MVTLabelLayerState = {
237
277
  key: unknown[];
238
278
  boxes: WeakMap<LabelRow, Float64Array>;
239
279
  };
280
+ /** Each row's icon parts with `icon-text-fit` (see `getFittedIconParts`). */
281
+ fittedIconParts?: {
282
+ key: unknown[];
283
+ parts: (FittedIconPart[] | null)[];
284
+ revision: number;
285
+ };
286
+ /** The data of each fitted icon layer, by its id (see `getFittedIconPieces`). */
287
+ fittedIconPieces?: Map<string, {
288
+ key: unknown[];
289
+ pieces: FittedIconPiece[];
290
+ }>;
240
291
  placementCommons?: {
241
292
  kind: string;
242
293
  positions: WeakMap<LabelRow, number[]>;
@@ -260,6 +311,7 @@ type MVTLabelLayerState = {
260
311
  glyphKey?: string;
261
312
  /** The map bearing, in `BEARING_STEP` steps, that upright line labels were turned for. */
262
313
  bearingStep?: number;
314
+ firstPersonText?: boolean;
263
315
  /** 1 while the layer waits for glyphs of the labels' text to load (see `hasLabelGlyphs`). */
264
316
  glyphLoads?: number;
265
317
  /** The glyph store the layer waits on while `glyphLoads` is 1. */
@@ -424,7 +476,7 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
424
476
  /** The tile whose anchors are being placed, in a `tiles` layer; see `getTileProps`. */
425
477
  private placingTile;
426
478
  /** The tile props that anchors are placed with: the tile being placed, or this layer's. */
427
- getTileProps(): Pick<MVTLabelLayerProps, 'tileBoundingBox' | 'tileZoom' | 'tileSize'>;
479
+ getTileProps(): Pick<MVTLabelLayerProps, 'tileBoundingBox' | 'tileZoom' | 'tileMaxZoom' | 'tileSize'>;
428
480
  /** A picked label of a `tiles` layer reports its tile. */
429
481
  getPickingInfo(params: any): any;
430
482
  /**
@@ -482,7 +534,8 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
482
534
  /**
483
535
  * One `IconLayer` per sprite that this layer's icons come from. Each holds every label row, so
484
536
  * an icon has the same row index, and so the same placement slot, as its own label. Rows whose
485
- * icon is in another sprite, or in none, draw nothing.
537
+ * icon is in another sprite, or in none, draw nothing. With `icon-text-fit`, a sprite's layer
538
+ * holds the quads of its rows' icons instead, each in its row's placement slot.
486
539
  *
487
540
  * `icon-image` is evaluated once per row. Each sprite's layer evaluates the other style
488
541
  * properties only for its own rows and gives every other row constants, so the style evaluation
@@ -491,6 +544,12 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
491
544
  * data cannot.
492
545
  */
493
546
  renderIconLayers(icons?: (ResolvedSpriteIcon | null)[]): any[];
547
+ /**
548
+ * The data of a fitted icon layer: the quads of each row whose icon is in `atlas`, and in the
549
+ * group's `rows`, in row order (see `FittedIconPiece`). It is kept while its inputs stay the
550
+ * same, so the layer's attributes are not made again at each render.
551
+ */
552
+ getFittedIconPieces(id: string, parts: (FittedIconPart[] | null)[], icons: (ResolvedSpriteIcon | null)[], rows: boolean[] | null | undefined, atlas: SpriteAtlas): FittedIconPiece[];
494
553
  /**
495
554
  * The label rows in the order every text and icon sublayer holds them: `labelData` in reverse.
496
555
  * A symbol's placement slot follows its index here, so an icon and its label share it; every
@@ -659,6 +718,30 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
659
718
  * zoom step is exact.
660
719
  */
661
720
  getLineHeight(): number;
721
+ /**
722
+ * The width and height in pixels of a feature's label at its `text-size`: its widest line, with
723
+ * letter spacing between characters, by its lines at `text-line-height`.
724
+ */
725
+ measureLabel(feature: FeatureLike, measure: (character: string) => number, lineHeight: number): [number, number];
726
+ /** `icon-text-fit` at the stepped zoom. */
727
+ getIconTextFit(): IconTextFit;
728
+ /**
729
+ * A row's icon stretched to its text by `icon-text-fit` (see `fitIconToText`), at `icon-size` 1.
730
+ * As in MapLibre, the text box is the one laid out for collision: at the collision text size, with
731
+ * `text-anchor` and `text-offset`. `icon-anchor` is not read.
732
+ */
733
+ getFittedIcon(row: LabelRow, icon: ResolvedSpriteIcon, textFit: IconTextFit, measure: (character: string) => number, lineHeight: number): FittedIcon;
734
+ /**
735
+ * The parts each label row's icon is drawn in with `icon-text-fit`, in `getRows` order: for a row
736
+ * with text, one per quad of its fitted icon (see `getIconQuads`); `null` for a row whose icon is
737
+ * drawn at its own size (it has no text) or that has no icon. Kept while the rows, their text,
738
+ * the sprites, the style's layout values, the font's measured widths and the zoom step are the
739
+ * same; `revision` changes when they are made again.
740
+ */
741
+ getFittedIconParts(icons: (ResolvedSpriteIcon | null)[], textFit: IconTextFit): {
742
+ parts: (FittedIconPart[] | null)[];
743
+ revision: number;
744
+ };
662
745
  /**
663
746
  * The tile's own extent in feature coordinates: the `[0, 1)` square for tile-local coordinates,
664
747
  * the tile's longitude/latitude box for globe tiles, or null when it is not known.
@@ -676,10 +759,10 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
676
759
  */
677
760
  getLabelAnchors(feature: FeatureLike, geographic?: boolean, placement?: string, budget?: PoleSearchBudget): number[][];
678
761
  /**
679
- * The zoom at which labels along lines are placed, and the tile's size in pixels there. As in
680
- * MapLibre, placement uses the tile's own zoom, so labels stay put while the map zooms within a
681
- * tile; an overzoomed tile is placed at the integer map zoom. A tile's own zoom is the map zoom
682
- * at which it is drawn `tileSize` pixels wide: one less than its tile zoom for 256 px tiles.
762
+ * Returns the placement zoom for line labels and the tile's pixel size at that zoom.
763
+ * The tile's own zoom accounts for its size. For a 256 px tile it is one less than its index zoom.
764
+ * At the source's deepest tile level, or if the limit is unknown, placement can scale up to
765
+ * the integer map zoom. Coarser tiles always use their own zoom.
683
766
  */
684
767
  getLinePlacementScale(): {
685
768
  zoom: number;
@@ -735,9 +818,9 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
735
818
  getLabelData(features: FeatureLike[], geographic: boolean): LabelRow[];
736
819
  /**
737
820
  * The inputs besides the tile data that the anchors depend on: `symbol-placement`, the
738
- * coordinate mode, the tile's extent and, for globe tiles, the search precision's zoom. Labels
739
- * along lines also depend on the placement scale and on the style values that size and space
740
- * them.
821
+ * coordinate mode, the tile's extent and, for geographic polygon anchors, the search precision's
822
+ * zoom. Labels along lines also depend on the placement scale and on the style values that size
823
+ * and space them.
741
824
  */
742
825
  getAnchorKey(geographic: boolean): string;
743
826
  /**
@@ -759,11 +842,14 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
759
842
  * needs a `text-field`, and icons an `icon-image` and loaded sprites.
760
843
  */
761
844
  turnsWithLines(): boolean;
845
+ /** First-person viewport pitch can be combined with map-relative rotation. */
846
+ usesMercatorLineBillboard(viewport?: unknown): boolean;
762
847
  /**
763
848
  * Text layer props for labels along lines: each label is turned to its line, upright when
764
849
  * `text-keep-upright` is set (the default). On a flat map they are drawn in the map plane, as
765
850
  * MapLibre does with the `auto` `text-rotation-alignment` and `text-pitch-alignment` of line
766
- * placement; on a globe they stay billboards, turned in screen space.
851
+ * placement. On a globe or in first-person with viewport pitch alignment, they follow the line
852
+ * in screen space.
767
853
  */
768
854
  getLineLabelProps(): Record<string, unknown>;
769
855
  /**
@@ -817,10 +903,9 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
817
903
  */
818
904
  placeRowGlyphs(row: LabelRow, line: RowLine, feature: FeatureLike, text: string, zoom: number): RowGlyphPlacements;
819
905
  /**
820
- * The extensions that keep billboards along lines on their lines on a globe. A globe draws them
821
- * in screen space, at angles taken from north up, so the shader turns them by the direction the
822
- * view draws the line in, at every frame, and upright with `keepUpright`: there the bearing
823
- * alone does not tell which way they read. A flat map draws them in the map plane. The shader
906
+ * The extensions that turn billboards to their lines in screen space. Globe labels and
907
+ * viewport-pitched road text use the direction the view draws the line at every frame.
908
+ * The shader
824
909
  * keeps an angle upright only when it is the line's direction: icons turned by `icon-rotate` are
825
910
  * kept upright from north up, by their angles. Text keeps its `text-offset` on its side of the
826
911
  * line as it turns around.
@@ -840,6 +925,12 @@ export declare class MVTLabelLayer extends CompositeLayer<MVTLabelLayerProps> {
840
925
  getAngle: ((row: LabelRow) => number) | null;
841
926
  extensions: GlobeLineAngleExtension[];
842
927
  };
928
+ /**
929
+ * The angle `text-rotate` turns each row's text by, counter-clockwise in degrees as deck.gl
930
+ * takes it, or null when the layer does not set it. Only point labels are turned: MapLibre turns
931
+ * each glyph along a line about its own center, which labels along lines do not do here.
932
+ */
933
+ getTextRotateAngle(): ((row: LabelRow) => number) | null;
843
934
  /**
844
935
  * Forgets a font load in flight, so that its completion does not update a finalized layer, and
845
936
  * releases the shared sprite textures.
@@ -0,0 +1,38 @@
1
+ import type { BasemapLoadOptions, BasemapSource } from "./style-resolver.js";
2
+ /** The URL prefix of a PMTiles archive, as in the `pmtiles` protocol of MapLibre GL JS. */
3
+ export declare const PMTILES_PROTOCOL = "pmtiles://";
4
+ /** Whether `url` names a PMTiles archive (`pmtiles://<archive URL>`). */
5
+ export declare function isPMTilesUrl(url: unknown): url is string;
6
+ /** The tile template of an archive: `pmtiles://<archive URL>/{z}/{x}/{y}`. */
7
+ export declare function getPMTilesTileTemplate(archiveUrl: string): string;
8
+ /** The archive URL and tile index of a tile URL, or null for another URL. */
9
+ export declare function parsePMTilesTileUrl(url: string): {
10
+ archiveUrl: string;
11
+ z: number;
12
+ x: number;
13
+ y: number;
14
+ } | null;
15
+ /**
16
+ * The most archive readers kept open per `fetch` and `fetchOptions`. Past it, the least recently
17
+ * used reader is released, with the header and directories it has read.
18
+ */
19
+ export declare const MAX_OPEN_ARCHIVES = 32;
20
+ /**
21
+ * The source fields of an archive, read from its header, as MapLibre GL JS's `pmtiles` protocol
22
+ * makes them: a tile template, `minzoom`, `maxzoom` and `bounds`. Throws if the archive cannot be
23
+ * read, or if its tiles are not of a type that a `sourceType` source draws, or are compressed with
24
+ * a method other than gzip.
25
+ */
26
+ export declare function getPMTilesSourceFields(archiveUrl: string, sourceType: string, loadOptions?: BasemapLoadOptions): Promise<Partial<BasemapSource>>;
27
+ /**
28
+ * A `fetch` that answers the URLs of PMTiles tile templates with the tile, read from its archive
29
+ * with range requests through the `fetch` and `fetchOptions` of `loadOptions`, and passes every
30
+ * other URL to that `fetch`. A tile the archive does not hold is an empty response (status 204).
31
+ */
32
+ export declare function createPMTilesFetch(loadOptions: BasemapLoadOptions | undefined): typeof fetch;
33
+ /**
34
+ * The load options that a source's tiles load with: for a source whose tiles are in a PMTiles
35
+ * archive, `loadOptions` with a `fetch` that reads them (see `createPMTilesFetch`), the same object
36
+ * for the same `loadOptions`; for every other source, `loadOptions` as they are.
37
+ */
38
+ export declare function getTileLoadOptions<LoadOptionsT extends BasemapLoadOptions | undefined>(source: BasemapSource, loadOptions: LoadOptionsT): LoadOptionsT;
@@ -0,0 +1,63 @@
1
+ import { CompositeLayer, FirstPersonViewport, type Color, type DefaultProps, type UpdateParameters, type Viewport } from '@deck.gl/core';
2
+ import { SolidPolygonLayer } from '@deck.gl/layers';
3
+ /** A square in the units of a view's coordinate reference system. */
4
+ export type BackgroundSquare = {
5
+ /** The center of the square. */
6
+ center: [number, number];
7
+ /** Half the side of the square. */
8
+ reach: number;
9
+ /** The reach that the view the square was made for needs. */
10
+ viewReach: number;
11
+ };
12
+ /** What `getBackgroundSquare` reads of a projected viewport. */
13
+ type BackgroundViewport = Pick<Viewport, 'width' | 'height' | 'scale' | 'center'> & {
14
+ pitch?: number;
15
+ unprojectFlat: (common: number[]) => number[];
16
+ };
17
+ /** Identify a geospatial first-person camera across copies of deck.gl. */
18
+ export declare function isGeographicFirstPersonViewport(viewport: unknown): viewport is FirstPersonViewport;
19
+ /**
20
+ * A square around the view center. Keep it while the view stays well inside it at a similar
21
+ * scale. A world-sized polygon can lose coverage when clipped against a first-person frustum
22
+ * or rendered at high zoom in a projected view.
23
+ */
24
+ export declare function getBackgroundSquare(viewport: BackgroundViewport, previous?: BackgroundSquare | null): BackgroundSquare | null;
25
+ /** Props of {@link ProjectedBackgroundLayer}. */
26
+ export type ProjectedBackgroundLayerProps = {
27
+ /** The fill color, `[r, g, b, a]`. */
28
+ getFillColor?: Color;
29
+ /**
30
+ * Whether the view is a Web Mercator map rather than a projected view: the square is then in
31
+ * longitude and latitude, cut at the latitudes of the Web Mercator world. A patterned background
32
+ * of a map draws such a square rather than the whole world, which leaves too little precision to
33
+ * place the pattern at high zoom.
34
+ */
35
+ geographic?: boolean;
36
+ /**
37
+ * `FillPatternExtension`'s pattern scale, in Web Mercator common units per image pixel. In a
38
+ * projected view the layer converts it to the view's common units, so that the pattern has the
39
+ * size it has on the Web Mercator map of the same scale.
40
+ */
41
+ getFillPatternScale?: number;
42
+ };
43
+ /**
44
+ * A background sized around a projected or first-person view. A geographic first-person view
45
+ * and a patterned Web Mercator background draw the square in longitude and latitude instead
46
+ * of projected coordinates (see `geographic`).
47
+ */
48
+ export declare class ProjectedBackgroundLayer extends CompositeLayer<ProjectedBackgroundLayerProps> {
49
+ static layerName: string;
50
+ static defaultProps: DefaultProps<ProjectedBackgroundLayerProps>;
51
+ state: {
52
+ square: BackgroundSquare | null;
53
+ polygons: number[][][];
54
+ /** The view's common units per Web Mercator common unit, where the square was made. */
55
+ commonScale: number;
56
+ };
57
+ initializeState(): void;
58
+ /** Also when the view leaves the square the background fills. */
59
+ shouldUpdateState(params: UpdateParameters<this>): boolean;
60
+ updateState(): void;
61
+ renderLayers(): SolidPolygonLayer<any, {}>;
62
+ }
63
+ export {};
@@ -0,0 +1,58 @@
1
+ import { BitmapLayer } from '@deck.gl/layers';
2
+ /** A mesh of a Web Mercator tile image, as `BitmapLayer` draws it. */
3
+ export type MercatorTileMesh = {
4
+ /** The count of indices. */
5
+ vertexCount: number;
6
+ /** Longitude, latitude and 0 of each vertex. */
7
+ positions: Float64Array;
8
+ /** The projected position of each vertex: what `BitmapLayer` draws. */
9
+ projectedPositions: Float64Array;
10
+ indices: Uint32Array;
11
+ /** The image coordinates of each vertex, with v down. */
12
+ texCoords: Float32Array;
13
+ };
14
+ /**
15
+ * Creates the mesh that draws a Web Mercator tile image in another projection. The image is
16
+ * uniform in Web Mercator space, so each vertex takes the longitude/latitude of its place in that
17
+ * space: a mesh uniform in latitude draws the image's rows at the wrong latitudes. The mesh is
18
+ * refined with math.gl's `subdivideTriangleMesh` until the sampled distance between the mesh and
19
+ * the projection is under half a texel. Where it cannot be refined, the tile is drawn with a
20
+ * fixed grid.
21
+ *
22
+ * `bounds` are the tile's `[west, south, east, north]`, and `project` converts longitude/latitude
23
+ * to the positions drawn. With `drawnBounds` (see `getNormalizedBounds`), only the part of the tile
24
+ * inside them has a mesh: outside the area of use of a projection, math.gl moves positions to its
25
+ * edge, and a mesh across that edge folds onto it. Its refinement follows the fold to its limit
26
+ * of triangles, and draws nothing more.
27
+ */
28
+ export declare function createMercatorTileMesh(bounds: ArrayLike<number>, project: (lngLat: number[]) => ArrayLike<number>, texels?: number, drawnBounds?: ArrayLike<number> | null): MercatorTileMesh;
29
+ /**
30
+ * The bounds, `[west, south, east, north]`, that a projection's normalization moves a tile to, or
31
+ * null. math.gl's normalization moves a position outside the area of use of an EPSG code, such as
32
+ * a UTM zone, to the nearest position on its edge: there it clamps longitude and latitude to a box.
33
+ * Returns that box clipped to the tile, if the normalization moves the four corners of the tile as
34
+ * such a clamp does, and null for another normalization, which then does not clip the tile. A
35
+ * tile outside the box gets bounds without area, on the edge of the box.
36
+ */
37
+ export declare function getNormalizedBounds(bounds: ArrayLike<number>, normalize: (position: number[]) => ArrayLike<number>): [number, number, number, number] | null;
38
+ /**
39
+ * A `BitmapLayer` for Web Mercator tile images that also draws in a projected view (deck.gl's
40
+ * `_CustomProjectionView`), with the mesh of `createMercatorTileMesh`. `BitmapLayer` itself draws
41
+ * a mesh uniform in longitude and latitude there, and its `_imageCoordinateSystem` has no effect.
42
+ * In other views it draws as `BitmapLayer` does.
43
+ */
44
+ export declare class ProjectedBitmapLayer<ExtraPropsT extends {} = {}> extends BitmapLayer<ExtraPropsT> {
45
+ static layerName: string;
46
+ protected _createMesh(): {
47
+ vertexCount: number;
48
+ positions: Float64Array<ArrayBuffer>;
49
+ projectedPositions: Float64Array<ArrayBuffer>;
50
+ indices: Uint32Array<ArrayBufferLike>;
51
+ texCoords: Float32Array<ArrayBuffer>;
52
+ } | {
53
+ vertexCount: number;
54
+ positions: Float64Array<ArrayBuffer>;
55
+ indices: Uint32Array<ArrayBuffer>;
56
+ texCoords: Float32Array<ArrayBuffer>;
57
+ };
58
+ }
@@ -0,0 +1,16 @@
1
+ type TileIndex = {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ };
6
+ /** The most vertices added to the features of one tile. Past it, steps are left whole. */
7
+ export declare const MAX_ADDED_VERTICES = 65536;
8
+ /**
9
+ * The features of a vector tile with longitude/latitude geometry, for a projected view, from the
10
+ * tile-local features a shared tileset holds. Lines and rings get vertices along their long
11
+ * steps (see `MAX_STEP`). The tileset's features are not changed: views of other kinds draw them
12
+ * too. The result is kept per feature array and tile, so that a tile's sublayers get the same
13
+ * data at each update.
14
+ */
15
+ export declare function getTileFeaturesInLngLat(features: any[], index: TileIndex): any[];
16
+ export {};
@@ -0,0 +1,72 @@
1
+ import { type ProjectedViewportLike } from "./projected-viewport.js";
2
+ /** The index of a Web Mercator (OSM) tile. */
3
+ export type ProjectedTileIndex = {
4
+ x: number;
5
+ y: number;
6
+ z: number;
7
+ };
8
+ /** Options of {@link getProjectedTileIndices}. */
9
+ export type ProjectedTileSelectionOptions = {
10
+ /** The tile zoom to select. */
11
+ z: number;
12
+ /** Longitude/latitude bounds `[west, south, east, north]` that limit the selection. */
13
+ extent?: ArrayLike<number> | null;
14
+ /**
15
+ * The most tiles to select. A view that needs more draws the tiles of a lower zoom: a projected
16
+ * view can show high latitudes, where Web Mercator tiles are small, far from its center.
17
+ */
18
+ maxTiles?: number;
19
+ /** The highest tile zoom of the source. Tiles are not divided past it. */
20
+ maxZoom?: number;
21
+ /** The lowest tile zoom of the source. No tiles of a lower zoom stand in for too many tiles. */
22
+ minZoom?: number;
23
+ /**
24
+ * How many times longer than at true scale the projection may draw a part of a tile's outline
25
+ * (see `isTileStretched`). Default `DEFAULT_MAX_STRETCH`. A projection that stretches the map
26
+ * smoothly toward the edge of its area of use, as a polar stereographic one, can take more: 16
27
+ * draws EPSG:3031 out to latitude 60N, where math.gl clamps its positions. A larger limit also
28
+ * stops seeing the places a projection cannot draw, as in a transverse Mercator projection of
29
+ * the whole world, whose tiles are then drawn across the map.
30
+ */
31
+ maxStretch?: number;
32
+ };
33
+ /** The default of `ProjectedTileSelectionOptions.maxStretch`. */
34
+ export declare const DEFAULT_MAX_STRETCH = 4;
35
+ /** The default of `ProjectedTileSelectionOptions.maxTiles`. */
36
+ export declare const DEFAULT_MAX_PROJECTED_TILES = 512;
37
+ /**
38
+ * The most tiles whose outline scale is kept for one projection. Past it the oldest is dropped:
39
+ * a view shows tens of tiles, and a zoom over the whole pyramid a few hundred.
40
+ */
41
+ export declare const MAX_KEPT_OUTLINE_SCALES = 4096;
42
+ /**
43
+ * Selects the Web Mercator tiles that a projected view shows, of one zoom where the projection
44
+ * draws them without stretch. deck.gl selects tiles
45
+ * for a Web Mercator view and a globe from the view frustum, with tiles as boxes in Web Mercator
46
+ * space; in a view of another projection a tile is neither a box nor, far from the projection's
47
+ * area of use, a shape at all.
48
+ *
49
+ * The tile pyramid is walked from its root. A tile is kept if a point of the screen lies in it,
50
+ * or if the view draws its outline across the screen: the first finds the tiles larger than the
51
+ * gaps between the screen points, the second the smaller ones. Both read only the
52
+ * view's `project` and `unproject`, so the selection holds for any projection, bearing and pitch.
53
+ *
54
+ * A selected tile that the projection stretches (see `isTileStretched`) is divided into the tiles
55
+ * of the next zooms, down to `EDGE_ZOOM`, and the parts still stretched are left out: a
56
+ * view zoomed out past the area the projection can draw shows the tiles around that area, and
57
+ * not geometry drawn across the map. Tiles come nearest the screen center first.
58
+ */
59
+ export declare function getProjectedTileIndices(viewport: ProjectedViewportLike, { z, extent, maxTiles, maxZoom, minZoom, maxStretch }: ProjectedTileSelectionOptions): ProjectedTileIndex[];
60
+ /**
61
+ * The zoom of the tiles a projected view draws, as deck.gl's `TileLayer` chooses it in a Web
62
+ * Mercator view, from the zoom of the Web Mercator map of the same scale (see `getMercatorZoom`):
63
+ * `zoomOffset` is added before the zoom is rounded. Returns null below `minZoom` without an
64
+ * `extent`, where `TileLayer` draws no tiles.
65
+ */
66
+ export declare function getProjectedTileZoom(viewport: ProjectedViewportLike, { tileSize, zoomOffset, minZoom, maxZoom, extent }: {
67
+ tileSize?: number;
68
+ zoomOffset?: number;
69
+ minZoom?: number;
70
+ maxZoom?: number;
71
+ extent?: ArrayLike<number> | null;
72
+ }): number | null;
@@ -0,0 +1,92 @@
1
+ import { sharedTile2DDeckAdapter } from '@deck.gl-community/layers/geo-layers';
2
+ import type { Viewport } from '@deck.gl/core';
3
+ import { TileLayer, Tileset2D } from '@deck.gl/geo-layers';
4
+ import { type SourceTileBounds } from "./source-tiles.js";
5
+ type DeckAdapter = typeof sharedTile2DDeckAdapter;
6
+ type TraversalContext = Parameters<DeckAdapter['getTileIndices']>[0];
7
+ type TileContext = Parameters<DeckAdapter['getTileBoundingBox']>[0];
8
+ type TileIndex = ReturnType<DeckAdapter['getTileIndices']>[number];
9
+ declare function createBasemapTilesetAdapter(maxStretch: number, tileBounds: SourceTileBounds | null): {
10
+ getTileIndices(context: Omit<TraversalContext, "viewState"> & {
11
+ viewState: unknown;
12
+ }): TileIndex[];
13
+ getTileBoundingBox(context: Omit<TileContext, "viewState"> & {
14
+ viewState: unknown;
15
+ }, index: TileIndex): import("@deck.gl-community/layers/geo-layers/tileset").TileBoundingBox;
16
+ };
17
+ type BasemapTilesetAdapter = ReturnType<typeof createBasemapTilesetAdapter>;
18
+ /**
19
+ * The tile traversal of the basemap's shared tilesets: deck.gl's in a Web Mercator view and on a
20
+ * globe, and `getProjectedTileIndices` with `maxStretch` (see `ProjectedTileSelectionOptions`) in
21
+ * a projected view. A tileset can serve views of both kinds at once, so the view is tested at
22
+ * each traversal. With `tileBounds`, a source's `bounds` (see `getSourceTileBounds`), the tiles
23
+ * outside them are not selected, so they are never requested. The same limit and the same bounds
24
+ * array give the same adapter. The cache holds a bounds array weakly: pass the array that
25
+ * `getSourceTileBounds` returns, which stays the same while the source's `bounds` do.
26
+ */
27
+ export declare function getBasemapTilesetAdapter(maxStretch?: number, tileBounds?: SourceTileBounds | null): BasemapTilesetAdapter;
28
+ /** `getBasemapTilesetAdapter` with the default stretch limit. */
29
+ export declare const basemapTilesetAdapter: {
30
+ getTileIndices(context: Omit<TraversalContext, "viewState"> & {
31
+ viewState: unknown;
32
+ }): TileIndex[];
33
+ getTileBoundingBox(context: Omit<TileContext, "viewState"> & {
34
+ viewState: unknown;
35
+ }, index: TileIndex): import("@deck.gl-community/layers/geo-layers/tileset").TileBoundingBox;
36
+ };
37
+ /**
38
+ * A deck.gl `Tileset2D` that also selects Web Mercator tiles in a projected view. Pass it to a
39
+ * `TileLayer` as `TilesetClass`. In other views it selects as `Tileset2D` does. With a
40
+ * `tileBounds` option (see `getSourceTileBounds`), the tiles outside the bounds are not selected.
41
+ */
42
+ export declare class ProjectedTileset2D<DataT = any, ViewStateT = Viewport> extends Tileset2D<DataT, ViewStateT> {
43
+ private selectionViewport;
44
+ getTileIndices(options: Parameters<Tileset2D<DataT, ViewStateT>['getTileIndices']>[0]): import("./projected-tile-selection.js").ProjectedTileIndex[];
45
+ /** The tiles that cover the view, before the `tileBounds` are applied. */
46
+ private getViewTileIndices;
47
+ /**
48
+ * `Tileset2D` culls tiles outside the longitude/latitude box of the screen corners. In a
49
+ * projected view a corner can lie outside the projection, without a longitude and latitude, and
50
+ * the selection has tested each tile against the screen already.
51
+ */
52
+ isTileVisible(...parameters: Parameters<Tileset2D<DataT, ViewStateT>['isTileVisible']>): boolean;
53
+ }
54
+ /**
55
+ * A deck.gl `TileLayer` that hands its `maxStretch` (see `ProjectedTileSelectionOptions`) and its
56
+ * `tileBounds` (see `getSourceTileBounds`) to a `ProjectedTileset2D`, its `TilesetClass`.
57
+ */
58
+ export declare class ProjectedTileLayer<DataT = any, ExtraPropsT extends {} = {}> extends TileLayer<DataT, ExtraPropsT & {
59
+ maxStretch?: number;
60
+ tileBounds?: SourceTileBounds | null;
61
+ }> {
62
+ static layerName: string;
63
+ static defaultProps: {
64
+ TilesetClass: typeof ProjectedTileset2D;
65
+ maxStretch: number;
66
+ tileBounds: null;
67
+ };
68
+ _getTilesetOptions(): {
69
+ maxStretch: number | undefined;
70
+ tileBounds: SourceTileBounds | null | undefined;
71
+ adapter?: import("@deck.gl/geo-layers").Tileset2DAdapter<Viewport> | null | undefined;
72
+ tileSource?: import("@loaders.gl/core/loader-utils").TileSource;
73
+ getTileData?: ((props: import("@deck.gl/geo-layers").TileLoadProps) => any) | undefined;
74
+ extent?: number[] | null;
75
+ tileSize?: number;
76
+ maxZoom?: number | null;
77
+ minZoom?: number | null;
78
+ maxCacheSize?: number | null;
79
+ maxCacheByteSize?: number | null;
80
+ refinementStrategy?: import("@deck.gl/geo-layers").RefinementStrategy;
81
+ zRange?: import("@deck.gl/geo-layers")._TileZRange | null;
82
+ maxRequests?: number;
83
+ debounceTime?: number;
84
+ zoomOffset?: number;
85
+ visibleMinZoom?: number | null;
86
+ visibleMaxZoom?: number | null;
87
+ onTileLoad?: ((tile: import("@deck.gl/geo-layers")._Tile2DHeader<any>) => void) | undefined;
88
+ onTileUnload?: ((tile: import("@deck.gl/geo-layers")._Tile2DHeader<any>) => void) | undefined;
89
+ onTileError?: ((err: any, tile: import("@deck.gl/geo-layers")._Tile2DHeader<any>) => void) | undefined;
90
+ };
91
+ }
92
+ export {};