@developmentseed/deck.gl-raster 0.5.0-beta.1 → 0.6.0-alpha.1

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 (81) hide show
  1. package/dist/gpu-modules/colormap-names.d.ts +128 -0
  2. package/dist/gpu-modules/colormap-names.d.ts.map +1 -0
  3. package/dist/gpu-modules/colormap-names.js +127 -0
  4. package/dist/gpu-modules/colormap-names.js.map +1 -0
  5. package/dist/gpu-modules/colormap.d.ts +28 -4
  6. package/dist/gpu-modules/colormap.d.ts.map +1 -1
  7. package/dist/gpu-modules/colormap.js +22 -5
  8. package/dist/gpu-modules/colormap.js.map +1 -1
  9. package/dist/gpu-modules/colormaps.png +0 -0
  10. package/dist/gpu-modules/composite-bands.d.ts +85 -0
  11. package/dist/gpu-modules/composite-bands.d.ts.map +1 -0
  12. package/dist/gpu-modules/composite-bands.js +141 -0
  13. package/dist/gpu-modules/composite-bands.js.map +1 -0
  14. package/dist/gpu-modules/create-colormap-texture.d.ts +16 -0
  15. package/dist/gpu-modules/create-colormap-texture.d.ts.map +1 -0
  16. package/dist/gpu-modules/create-colormap-texture.js +41 -0
  17. package/dist/gpu-modules/create-colormap-texture.js.map +1 -0
  18. package/dist/gpu-modules/cutline-bbox.d.ts +70 -0
  19. package/dist/gpu-modules/cutline-bbox.d.ts.map +1 -0
  20. package/dist/gpu-modules/cutline-bbox.js +100 -0
  21. package/dist/gpu-modules/cutline-bbox.js.map +1 -0
  22. package/dist/gpu-modules/decode-colormap-sprite.d.ts +25 -0
  23. package/dist/gpu-modules/decode-colormap-sprite.d.ts.map +1 -0
  24. package/dist/gpu-modules/decode-colormap-sprite.js +51 -0
  25. package/dist/gpu-modules/decode-colormap-sprite.js.map +1 -0
  26. package/dist/gpu-modules/index.d.ts +12 -1
  27. package/dist/gpu-modules/index.d.ts.map +1 -1
  28. package/dist/gpu-modules/index.js +7 -1
  29. package/dist/gpu-modules/index.js.map +1 -1
  30. package/dist/gpu-modules/linear-rescale.d.ts +39 -0
  31. package/dist/gpu-modules/linear-rescale.d.ts.map +1 -0
  32. package/dist/gpu-modules/linear-rescale.js +40 -0
  33. package/dist/gpu-modules/linear-rescale.js.map +1 -0
  34. package/dist/gpu-modules/types.d.ts +10 -1
  35. package/dist/gpu-modules/types.d.ts.map +1 -1
  36. package/dist/index.d.ts +5 -9
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +4 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/layer-utils.d.ts +28 -0
  41. package/dist/layer-utils.d.ts.map +1 -0
  42. package/dist/layer-utils.js +56 -0
  43. package/dist/layer-utils.js.map +1 -0
  44. package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
  45. package/dist/mesh-layer/mesh-layer.js +10 -1
  46. package/dist/mesh-layer/mesh-layer.js.map +1 -1
  47. package/dist/multi-raster-tileset/index.d.ts +5 -0
  48. package/dist/multi-raster-tileset/index.d.ts.map +1 -0
  49. package/dist/multi-raster-tileset/index.js +3 -0
  50. package/dist/multi-raster-tileset/index.js.map +1 -0
  51. package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts +75 -0
  52. package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts.map +1 -0
  53. package/dist/multi-raster-tileset/multi-tileset-descriptor.js +97 -0
  54. package/dist/multi-raster-tileset/multi-tileset-descriptor.js.map +1 -0
  55. package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts +129 -0
  56. package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts.map +1 -0
  57. package/dist/multi-raster-tileset/secondary-tile-resolver.js +88 -0
  58. package/dist/multi-raster-tileset/secondary-tile-resolver.js.map +1 -0
  59. package/dist/raster-tileset/index.d.ts +4 -1
  60. package/dist/raster-tileset/index.d.ts.map +1 -1
  61. package/dist/raster-tileset/index.js +2 -1
  62. package/dist/raster-tileset/index.js.map +1 -1
  63. package/dist/raster-tileset/raster-tile-traversal.d.ts +29 -51
  64. package/dist/raster-tileset/raster-tile-traversal.d.ts.map +1 -1
  65. package/dist/raster-tileset/raster-tile-traversal.js +113 -171
  66. package/dist/raster-tileset/raster-tile-traversal.js.map +1 -1
  67. package/dist/raster-tileset/raster-tileset-2d.d.ts +8 -22
  68. package/dist/raster-tileset/raster-tileset-2d.d.ts.map +1 -1
  69. package/dist/raster-tileset/raster-tileset-2d.js +30 -81
  70. package/dist/raster-tileset/raster-tileset-2d.js.map +1 -1
  71. package/dist/raster-tileset/tile-matrix-set.d.ts +20 -0
  72. package/dist/raster-tileset/tile-matrix-set.d.ts.map +1 -0
  73. package/dist/raster-tileset/tile-matrix-set.js +121 -0
  74. package/dist/raster-tileset/tile-matrix-set.js.map +1 -0
  75. package/dist/raster-tileset/tileset-interface.d.ts +78 -0
  76. package/dist/raster-tileset/tileset-interface.d.ts.map +1 -0
  77. package/dist/raster-tileset/tileset-interface.js +2 -0
  78. package/dist/raster-tileset/tileset-interface.js.map +1 -0
  79. package/dist/raster-tileset/types.d.ts +10 -18
  80. package/dist/raster-tileset/types.d.ts.map +1 -1
  81. package/package.json +17 -16
@@ -0,0 +1,75 @@
1
+ import type { TilesetDescriptor, TilesetLevel } from "../raster-tileset/tileset-interface.js";
2
+ import type { Bounds, ProjectionFunction } from "../raster-tileset/types.js";
3
+ /**
4
+ * Groups N {@link TilesetDescriptor}s representing the same geographic extent
5
+ * at different native resolutions.
6
+ *
7
+ * The {@link primary} tileset (finest resolution) drives tile traversal;
8
+ * {@link secondaries} are consulted at fetch time to resolve covering tiles
9
+ * and compute UV transforms.
10
+ *
11
+ * @see {@link createMultiTilesetDescriptor} to construct from a named map of tilesets
12
+ */
13
+ export interface MultiTilesetDescriptor {
14
+ /** Highest-resolution tileset — drives tile traversal. */
15
+ primary: TilesetDescriptor;
16
+ /** The key under which the primary was provided to {@link createMultiTilesetDescriptor}. */
17
+ primaryKey: string;
18
+ /** Lower-resolution tilesets, keyed by user-defined name. */
19
+ secondaries: Map<string, TilesetDescriptor>;
20
+ /** Shared CRS bounds (from primary's {@link TilesetDescriptor.projectedBounds}). */
21
+ bounds: Bounds;
22
+ /** Shared projection: source CRS -> EPSG:3857. */
23
+ projectTo3857: ProjectionFunction;
24
+ /** Shared projection: source CRS -> EPSG:4326. */
25
+ projectTo4326: ProjectionFunction;
26
+ }
27
+ /**
28
+ * Create a {@link MultiTilesetDescriptor} from a map of named tilesets.
29
+ *
30
+ * Automatically selects the tileset with the finest
31
+ * {@link TilesetLevel.metersPerPixel} at its highest-resolution level as the
32
+ * primary. All others become secondaries.
33
+ *
34
+ * @param tilesets - Named tilesets, e.g. `new Map([["B04", band10m], ["B11", band20m]])`
35
+ * @throws If `tilesets` is empty
36
+ */
37
+ export declare function createMultiTilesetDescriptor(tilesets: Map<string, TilesetDescriptor>): MultiTilesetDescriptor;
38
+ /**
39
+ * Strategy for selecting a secondary tileset level.
40
+ *
41
+ * - `"closest"` — Pick the level whose `metersPerPixel` is nearest to the
42
+ * primary's, in either direction. Minimizes wasted bandwidth but may return
43
+ * a slightly coarser level than necessary.
44
+ * - `"closest-finer"` — Prefer the finest level whose `metersPerPixel` is
45
+ * <= the primary's. Falls back to the finest available if all levels are
46
+ * coarser. Ensures the secondary is never blurrier than necessary when a
47
+ * finer option exists.
48
+ */
49
+ export type SecondaryLevelStrategy = "closest" | "closest-finer";
50
+ /**
51
+ * Select the best {@link TilesetLevel} from a secondary tileset for a given
52
+ * primary {@link TilesetLevel.metersPerPixel}.
53
+ *
54
+ * @param levels - Ordered coarsest-first (index 0 = coarsest), matching
55
+ * {@link TilesetDescriptor.levels} convention
56
+ * @param primaryMetersPerPixel - The `metersPerPixel` of the current primary
57
+ * tile's zoom level
58
+ * @param strategy - Selection strategy. Defaults to `"closest-finer"`.
59
+ * @returns The selected {@link TilesetLevel}
60
+ *
61
+ * @see {@link SecondaryLevelStrategy} for available strategies
62
+ */
63
+ export declare function selectSecondaryLevel(levels: TilesetLevel[], primaryMetersPerPixel: number, strategy?: SecondaryLevelStrategy): TilesetLevel;
64
+ /**
65
+ * Check if two {@link TilesetLevel}s have the same grid parameters.
66
+ *
67
+ * Used to detect when sources share a tile grid and can skip UV transform
68
+ * computation (e.g., all 10m Sentinel-2 bands share the same grid).
69
+ *
70
+ * Compares {@link TilesetLevel.matrixWidth}, {@link TilesetLevel.matrixHeight},
71
+ * {@link TilesetLevel.tileWidth}, {@link TilesetLevel.tileHeight}, and
72
+ * {@link TilesetLevel.metersPerPixel}.
73
+ */
74
+ export declare function tilesetLevelsEqual(a: TilesetLevel, b: TilesetLevel): boolean;
75
+ //# sourceMappingURL=multi-tileset-descriptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-tileset-descriptor.d.ts","sourceRoot":"","sources":["../../src/multi-raster-tileset/multi-tileset-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACb,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE7E;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC5C,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,aAAa,EAAE,kBAAkB,CAAC;IAClC,kDAAkD;IAClD,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACvC,sBAAsB,CA4BxB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EAAE,EACtB,qBAAqB,EAAE,MAAM,EAC7B,QAAQ,GAAE,sBAAwC,GACjD,YAAY,CA2Bd;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,OAAO,CAQ5E"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Create a {@link MultiTilesetDescriptor} from a map of named tilesets.
3
+ *
4
+ * Automatically selects the tileset with the finest
5
+ * {@link TilesetLevel.metersPerPixel} at its highest-resolution level as the
6
+ * primary. All others become secondaries.
7
+ *
8
+ * @param tilesets - Named tilesets, e.g. `new Map([["B04", band10m], ["B11", band20m]])`
9
+ * @throws If `tilesets` is empty
10
+ */
11
+ export function createMultiTilesetDescriptor(tilesets) {
12
+ if (tilesets.size === 0) {
13
+ throw new Error("At least one tileset is required");
14
+ }
15
+ let primaryKey = null;
16
+ let finestMpp = Number.POSITIVE_INFINITY;
17
+ for (const [key, descriptor] of tilesets) {
18
+ const finestLevel = descriptor.levels[descriptor.levels.length - 1];
19
+ if (finestLevel && finestLevel.metersPerPixel < finestMpp) {
20
+ finestMpp = finestLevel.metersPerPixel;
21
+ primaryKey = key;
22
+ }
23
+ }
24
+ const primary = tilesets.get(primaryKey);
25
+ const secondaries = new Map();
26
+ for (const [key, descriptor] of tilesets) {
27
+ if (key !== primaryKey) {
28
+ secondaries.set(key, descriptor);
29
+ }
30
+ }
31
+ return {
32
+ primary,
33
+ primaryKey: primaryKey,
34
+ secondaries,
35
+ bounds: primary.projectedBounds,
36
+ projectTo3857: primary.projectTo3857,
37
+ projectTo4326: primary.projectTo4326,
38
+ };
39
+ }
40
+ /**
41
+ * Select the best {@link TilesetLevel} from a secondary tileset for a given
42
+ * primary {@link TilesetLevel.metersPerPixel}.
43
+ *
44
+ * @param levels - Ordered coarsest-first (index 0 = coarsest), matching
45
+ * {@link TilesetDescriptor.levels} convention
46
+ * @param primaryMetersPerPixel - The `metersPerPixel` of the current primary
47
+ * tile's zoom level
48
+ * @param strategy - Selection strategy. Defaults to `"closest-finer"`.
49
+ * @returns The selected {@link TilesetLevel}
50
+ *
51
+ * @see {@link SecondaryLevelStrategy} for available strategies
52
+ */
53
+ export function selectSecondaryLevel(levels, primaryMetersPerPixel, strategy = "closest-finer") {
54
+ if (strategy === "closest-finer") {
55
+ // Among levels that are finer-or-equal to the primary, pick the closest
56
+ // (coarsest of the finer-or-equal set). Walk from coarsest to finest,
57
+ // tracking the last level that's <= primary.
58
+ let bestFiner = null;
59
+ for (let i = 0; i < levels.length; i++) {
60
+ if (levels[i].metersPerPixel <= primaryMetersPerPixel) {
61
+ bestFiner = levels[i];
62
+ break;
63
+ }
64
+ }
65
+ // If found, return it; otherwise fall back to the finest available
66
+ return bestFiner ?? levels[levels.length - 1];
67
+ }
68
+ // "closest" — pick the level with the smallest absolute difference
69
+ let best = levels[0];
70
+ let bestDiff = Math.abs(best.metersPerPixel - primaryMetersPerPixel);
71
+ for (let i = 1; i < levels.length; i++) {
72
+ const diff = Math.abs(levels[i].metersPerPixel - primaryMetersPerPixel);
73
+ if (diff < bestDiff) {
74
+ bestDiff = diff;
75
+ best = levels[i];
76
+ }
77
+ }
78
+ return best;
79
+ }
80
+ /**
81
+ * Check if two {@link TilesetLevel}s have the same grid parameters.
82
+ *
83
+ * Used to detect when sources share a tile grid and can skip UV transform
84
+ * computation (e.g., all 10m Sentinel-2 bands share the same grid).
85
+ *
86
+ * Compares {@link TilesetLevel.matrixWidth}, {@link TilesetLevel.matrixHeight},
87
+ * {@link TilesetLevel.tileWidth}, {@link TilesetLevel.tileHeight}, and
88
+ * {@link TilesetLevel.metersPerPixel}.
89
+ */
90
+ export function tilesetLevelsEqual(a, b) {
91
+ return (a.matrixWidth === b.matrixWidth &&
92
+ a.matrixHeight === b.matrixHeight &&
93
+ a.tileWidth === b.tileWidth &&
94
+ a.tileHeight === b.tileHeight &&
95
+ a.metersPerPixel === b.metersPerPixel);
96
+ }
97
+ //# sourceMappingURL=multi-tileset-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-tileset-descriptor.js","sourceRoot":"","sources":["../../src/multi-raster-tileset/multi-tileset-descriptor.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAwC;IAExC,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,UAAU,GAAkB,IAAI,CAAC;IACrC,IAAI,SAAS,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzC,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpE,IAAI,WAAW,IAAI,WAAW,CAAC,cAAc,GAAG,SAAS,EAAE,CAAC;YAC1D,SAAS,GAAG,WAAW,CAAC,cAAc,CAAC;YACvC,UAAU,GAAG,GAAG,CAAC;QACnB,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAW,CAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;IACzD,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzC,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO;QACL,OAAO;QACP,UAAU,EAAE,UAAW;QACvB,WAAW;QACX,MAAM,EAAE,OAAO,CAAC,eAAe;QAC/B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,aAAa,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kB,CAAC,CAAe,EAAE,CAAe;IACjE,OAAO,CACL,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QACjC,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;QAC3B,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAC7B,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,cAAc,CACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,129 @@
1
+ import type { TilesetLevel } from "../raster-tileset/tileset-interface.js";
2
+ /**
3
+ * UV transform mapping primary tile UV space to the correct sub-region of a
4
+ * band texture.
5
+ *
6
+ * Applied in the shader as: `sampledUV = uv * [scaleX, scaleY] + [offsetX, offsetY]`
7
+ *
8
+ * Defined as a tuple so it can be uploaded directly to the GPU as a vec4 uniform.
9
+ *
10
+ * Elements:
11
+ * - `offsetX` — horizontal offset: left edge of the primary tile within the band texture, in UV units
12
+ * - `offsetY` — vertical offset: top edge of the primary tile within the band texture, in UV units
13
+ * - `scaleX` — horizontal scale: fraction of the band texture width covered by the primary tile
14
+ * - `scaleY` — vertical scale: fraction of the band texture height covered by the primary tile
15
+ */
16
+ export type UvTransform = readonly [
17
+ offsetX: number,
18
+ offsetY: number,
19
+ scaleX: number,
20
+ scaleY: number
21
+ ];
22
+ /**
23
+ * A tile index in a secondary tileset.
24
+ *
25
+ * Uses `x`/`y` naming to match {@link TileIndex} convention.
26
+ *
27
+ * @see {@link SecondaryTileResolution}
28
+ */
29
+ export interface SecondaryTileIndex {
30
+ /** Column index of the secondary tile. */
31
+ x: number;
32
+ /** Row index of the secondary tile. */
33
+ y: number;
34
+ }
35
+ /**
36
+ * Result of resolving secondary tiles for a primary tile.
37
+ *
38
+ * @see {@link resolveSecondaryTiles}
39
+ */
40
+ export interface SecondaryTileResolution {
41
+ /**
42
+ * The secondary tile indices that cover the primary tile's extent.
43
+ *
44
+ * When the primary tile falls within a single secondary tile, this array
45
+ * has one element. When the primary tile straddles a boundary, it may
46
+ * contain multiple entries that must be stitched together.
47
+ */
48
+ tileIndices: SecondaryTileIndex[];
49
+ /**
50
+ * UV transform: `[offsetX, offsetY, scaleX, scaleY]`.
51
+ *
52
+ * Maps from the primary tile's UV space [0,1]^2 to the correct sub-region
53
+ * of the stitched secondary texture.
54
+ *
55
+ * Usage in shader: `sampledUV = uv * scale + offset`
56
+ *
57
+ * - `offsetX`, `offsetY`: top-left corner of the primary tile's footprint
58
+ * within the stitched texture, in UV units.
59
+ * - `scaleX`, `scaleY`: fraction of the stitched texture covered by the
60
+ * primary tile.
61
+ */
62
+ uvTransform: UvTransform;
63
+ /**
64
+ * The total stitched texture width in pixels.
65
+ *
66
+ * Equals the number of tile columns in the covering range times the
67
+ * secondary tile width. For example, if 2 tiles of 256px wide are
68
+ * fetched, `stitchedWidth` is 512.
69
+ */
70
+ stitchedWidth: number;
71
+ /**
72
+ * The total stitched texture height in pixels.
73
+ *
74
+ * Equals the number of tile rows in the covering range times the
75
+ * secondary tile height. For example, if 2 tiles of 256px tall are
76
+ * fetched, `stitchedHeight` is 512.
77
+ */
78
+ stitchedHeight: number;
79
+ /**
80
+ * The minimum column index of the secondary tile range.
81
+ *
82
+ * Used when stitching: tells you where each fetched tile goes in the
83
+ * stitched buffer (tile at column `col` starts at pixel
84
+ * `(col - minCol) * tileWidth`).
85
+ */
86
+ minCol: number;
87
+ /**
88
+ * The minimum row index of the secondary tile range.
89
+ *
90
+ * Used when stitching: tells you where each fetched tile goes in the
91
+ * stitched buffer (tile at row `row` starts at pixel
92
+ * `(row - minRow) * tileHeight`).
93
+ */
94
+ minRow: number;
95
+ /**
96
+ * Zoom level index into {@link TilesetDescriptor.levels}.
97
+ *
98
+ * All tiles in {@link tileIndices} come from this same level. Tells the
99
+ * consumer which COG overview to fetch from.
100
+ */
101
+ z: number;
102
+ }
103
+ /**
104
+ * Resolve which secondary tiles cover a primary tile's extent, and compute
105
+ * the UV transform to map from primary UV space into the stitched secondary
106
+ * texture.
107
+ *
108
+ * The UV transform `[offsetX, offsetY, scaleX, scaleY]` is intended for use
109
+ * in a shader as `sampledUV = uv * scale + offset`, where `uv` is the
110
+ * primary tile's local UV coordinate in [0,1]^2.
111
+ *
112
+ * The Y axis follows a top-left convention: origin is at the top-left corner,
113
+ * Y increases downward in texture/UV space. CRS coordinates may increase
114
+ * upward (north), so `offsetY` is computed as
115
+ * `(stitchedMaxY - primaryMaxY) / stitchedCrsHeight` to account for the flip.
116
+ *
117
+ * @param primaryLevel - The {@link TilesetLevel} describing the primary tileset.
118
+ * @param primaryCol - Column index of the primary tile.
119
+ * @param primaryRow - Row index of the primary tile.
120
+ * @param secondaryLevel - The {@link TilesetLevel} describing the secondary tileset.
121
+ * @param secondaryZ - The zoom level index of `secondaryLevel` within its
122
+ * {@link TilesetDescriptor.levels} array. Stored in the returned
123
+ * {@link SecondaryTileResolution.z} so the consumer knows which COG overview
124
+ * to fetch.
125
+ * @returns A {@link SecondaryTileResolution} with tile indices, UV transform,
126
+ * stitched dimensions, and the min col/row of the covered range.
127
+ */
128
+ export declare function resolveSecondaryTiles(primaryLevel: TilesetLevel, primaryCol: number, primaryRow: number, secondaryLevel: TilesetLevel, secondaryZ: number): SecondaryTileResolution;
129
+ //# sourceMappingURL=secondary-tile-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondary-tile-resolver.d.ts","sourceRoot":"","sources":["../../src/multi-raster-tileset/secondary-tile-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS;IACjC,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;CACf,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,CAAC,EAAE,MAAM,CAAC;IACV,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAElC;;;;;;;;;;;;OAYG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,YAAY,EAC5B,UAAU,EAAE,MAAM,GACjB,uBAAuB,CAqGzB"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Resolve which secondary tiles cover a primary tile's extent, and compute
3
+ * the UV transform to map from primary UV space into the stitched secondary
4
+ * texture.
5
+ *
6
+ * The UV transform `[offsetX, offsetY, scaleX, scaleY]` is intended for use
7
+ * in a shader as `sampledUV = uv * scale + offset`, where `uv` is the
8
+ * primary tile's local UV coordinate in [0,1]^2.
9
+ *
10
+ * The Y axis follows a top-left convention: origin is at the top-left corner,
11
+ * Y increases downward in texture/UV space. CRS coordinates may increase
12
+ * upward (north), so `offsetY` is computed as
13
+ * `(stitchedMaxY - primaryMaxY) / stitchedCrsHeight` to account for the flip.
14
+ *
15
+ * @param primaryLevel - The {@link TilesetLevel} describing the primary tileset.
16
+ * @param primaryCol - Column index of the primary tile.
17
+ * @param primaryRow - Row index of the primary tile.
18
+ * @param secondaryLevel - The {@link TilesetLevel} describing the secondary tileset.
19
+ * @param secondaryZ - The zoom level index of `secondaryLevel` within its
20
+ * {@link TilesetDescriptor.levels} array. Stored in the returned
21
+ * {@link SecondaryTileResolution.z} so the consumer knows which COG overview
22
+ * to fetch.
23
+ * @returns A {@link SecondaryTileResolution} with tile indices, UV transform,
24
+ * stitched dimensions, and the min col/row of the covered range.
25
+ */
26
+ export function resolveSecondaryTiles(primaryLevel, primaryCol, primaryRow, secondaryLevel, secondaryZ) {
27
+ // Step 1: Get the CRS extent of the primary tile
28
+ const corners = primaryLevel.projectedTileCorners(primaryCol, primaryRow);
29
+ const primaryMinX = Math.min(corners.topLeft[0], corners.bottomLeft[0], corners.topRight[0], corners.bottomRight[0]);
30
+ const primaryMaxX = Math.max(corners.topLeft[0], corners.bottomLeft[0], corners.topRight[0], corners.bottomRight[0]);
31
+ const primaryMinY = Math.min(corners.topLeft[1], corners.bottomLeft[1], corners.topRight[1], corners.bottomRight[1]);
32
+ const primaryMaxY = Math.max(corners.topLeft[1], corners.bottomLeft[1], corners.topRight[1], corners.bottomRight[1]);
33
+ // Step 2: Find covering secondary tiles
34
+ const range = secondaryLevel.crsBoundsToTileRange(primaryMinX, primaryMinY, primaryMaxX, primaryMaxY);
35
+ const tileIndices = [];
36
+ for (let row = range.minRow; row <= range.maxRow; row++) {
37
+ for (let col = range.minCol; col <= range.maxCol; col++) {
38
+ tileIndices.push({ x: col, y: row });
39
+ }
40
+ }
41
+ // Step 3: Compute the CRS extent of the stitched secondary region
42
+ const minCorners = secondaryLevel.projectedTileCorners(range.minCol, range.minRow);
43
+ const maxCorners = secondaryLevel.projectedTileCorners(range.maxCol, range.maxRow);
44
+ const allCornerPoints = [
45
+ minCorners.topLeft,
46
+ minCorners.topRight,
47
+ minCorners.bottomLeft,
48
+ minCorners.bottomRight,
49
+ maxCorners.topLeft,
50
+ maxCorners.topRight,
51
+ maxCorners.bottomLeft,
52
+ maxCorners.bottomRight,
53
+ ];
54
+ const stitchedMinX = Math.min(...allCornerPoints.map((p) => p[0]));
55
+ const stitchedMaxX = Math.max(...allCornerPoints.map((p) => p[0]));
56
+ const stitchedMinY = Math.min(...allCornerPoints.map((p) => p[1]));
57
+ const stitchedMaxY = Math.max(...allCornerPoints.map((p) => p[1]));
58
+ const stitchedCrsWidth = stitchedMaxX - stitchedMinX;
59
+ const stitchedCrsHeight = stitchedMaxY - stitchedMinY;
60
+ // Step 4: Compute UV transform.
61
+ // offsetX: how far the primary tile's left edge is from the stitched left edge.
62
+ // offsetY: how far the primary tile's top edge is from the stitched top edge.
63
+ // CRS Y increases upward, but UV Y increases downward, so we use
64
+ // (stitchedMaxY - primaryMaxY) for the top-edge offset.
65
+ const primaryCrsWidth = primaryMaxX - primaryMinX;
66
+ const primaryCrsHeight = primaryMaxY - primaryMinY;
67
+ const scaleX = stitchedCrsWidth > 0 ? primaryCrsWidth / stitchedCrsWidth : 1;
68
+ const scaleY = stitchedCrsHeight > 0 ? primaryCrsHeight / stitchedCrsHeight : 1;
69
+ const offsetX = stitchedCrsWidth > 0 ? (primaryMinX - stitchedMinX) / stitchedCrsWidth : 0;
70
+ const offsetY = stitchedCrsHeight > 0
71
+ ? (stitchedMaxY - primaryMaxY) / stitchedCrsHeight
72
+ : 0;
73
+ // Step 5: Stitched pixel dimensions
74
+ const numCols = range.maxCol - range.minCol + 1;
75
+ const numRows = range.maxRow - range.minRow + 1;
76
+ const stitchedWidth = numCols * secondaryLevel.tileWidth;
77
+ const stitchedHeight = numRows * secondaryLevel.tileHeight;
78
+ return {
79
+ tileIndices,
80
+ uvTransform: [offsetX, offsetY, scaleX, scaleY],
81
+ stitchedWidth,
82
+ stitchedHeight,
83
+ minCol: range.minCol,
84
+ minRow: range.minRow,
85
+ z: secondaryZ,
86
+ };
87
+ }
88
+ //# sourceMappingURL=secondary-tile-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondary-tile-resolver.js","sourceRoot":"","sources":["../../src/multi-raster-tileset/secondary-tile-resolver.ts"],"names":[],"mappings":"AAgHA;;;;;;;;;;;;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,GAAG,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC;IAE3D,OAAO;QACL,WAAW;QACX,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;QAC/C,aAAa;QACb,cAAc;QACd,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,CAAC,EAAE,UAAU;KACd,CAAC;AACJ,CAAC"}
@@ -1,3 +1,6 @@
1
1
  export type { TileMetadata } from "./raster-tileset-2d.js";
2
- export { TileMatrixSetTileset } from "./raster-tileset-2d.js";
2
+ export { RasterTileset2D } from "./raster-tileset-2d.js";
3
+ export { TileMatrixSetAdaptor } from "./tile-matrix-set.js";
4
+ export type { TilesetDescriptor, TilesetLevel } from "./tileset-interface.js";
5
+ export type { Bounds, CornerBounds, Corners, ProjectionFunction, } from "./types.js";
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -1,2 +1,3 @@
1
- export { TileMatrixSetTileset } from "./raster-tileset-2d.js";
1
+ export { RasterTileset2D } from "./raster-tileset-2d.js";
2
+ export { TileMatrixSetAdaptor } from "./tile-matrix-set.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/raster-tileset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/raster-tileset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,6 +1,5 @@
1
1
  /**
2
- * This file implements tile traversal for generic 2D tilesets defined by
3
- * TileMatrixSet tile layouts.
2
+ * This file implements tile traversal for generic 2D tilesets.
4
3
  *
5
4
  * The main algorithm works as follows:
6
5
  *
@@ -8,26 +7,29 @@
8
7
  * necessarily the whole world)
9
8
  * 2. Test if each tile is visible using viewport frustum culling
10
9
  * 3. For visible tiles, compute distance-based LOD (Level of Detail)
11
- * 4. If LOD is insufficient, recursively subdivide into 4 child tiles
10
+ * 4. If LOD is insufficient, recursively subdivide into child tiles
12
11
  * 5. Select tiles at appropriate zoom levels based on distance from camera
13
12
  *
14
13
  * The result is a set of tiles at varying zoom levels that efficiently
15
14
  * cover the visible area with appropriate detail.
15
+ *
16
+ * The traversal is driven by a {@link TilesetDescriptor}, which abstracts over
17
+ * both OGC TileMatrixSet grids and Zarr multiscale pyramids.
16
18
  */
17
19
  import type { Viewport } from "@deck.gl/core";
18
- import type { TileMatrix, TileMatrixSet } from "@developmentseed/morecantile";
19
20
  import type { OrientedBoundingBox } from "@math.gl/culling";
20
21
  import { CullingVolume } from "@math.gl/culling";
21
- import type { Bounds, CornerBounds, ProjectionFunction, TileIndex, ZRange } from "./types.js";
22
+ import type { TilesetDescriptor, TilesetLevel } from "./tileset-interface.js";
23
+ import type { Bounds, TileIndex, ZRange } from "./types.js";
22
24
  /**
23
- * Raster Tile Node - represents a single tile in the TileMatrixSet structure
25
+ * Raster Tile Node - represents a single tile in a tileset pyramid.
24
26
  *
25
27
  * Akin to the upstream OSMNode class.
26
28
  *
27
29
  * This node class uses the following coordinate system:
28
30
  *
29
- * - x: tile column (0 to TileMatrix.matrixWidth, left to right)
30
- * - y: tile row (0 to TileMatrix.matrixHeight, top to bottom)
31
+ * - x: tile column (0 to TilesetLevel.matrixWidth, left to right)
32
+ * - y: tile row (0 to TilesetLevel.matrixHeight, top to bottom)
31
33
  * - z: overview level. This assumes ordering where: 0 = coarsest, higher = finer
32
34
  */
33
35
  export declare class RasterTileNode {
@@ -37,7 +39,7 @@ export declare class RasterTileNode {
37
39
  y: number;
38
40
  /** Zoom index assumed to be (higher = finer detail) */
39
41
  z: number;
40
- private metadata;
42
+ private descriptor;
41
43
  /**
42
44
  * Flag indicating whether any descendant of this tile is visible.
43
45
  *
@@ -53,35 +55,32 @@ export declare class RasterTileNode {
53
55
  private selected?;
54
56
  /** A cache of the children of this node. */
55
57
  private _children?;
56
- private projectTo3857;
57
- private projectTo4326;
58
58
  /**
59
59
  * A cached bounding volume for this tile, used for frustum culling
60
60
  *
61
61
  * This stores the result of `getBoundingVolume`.
62
62
  */
63
63
  private _boundingVolume?;
64
- constructor(x: number, y: number, z: number, { metadata, projectTo3857, projectTo4326, }: {
65
- metadata: TileMatrixSet;
66
- projectTo3857: ProjectionFunction;
67
- projectTo4326: ProjectionFunction;
64
+ constructor(x: number, y: number, z: number, { descriptor }: {
65
+ descriptor: TilesetDescriptor;
68
66
  });
69
- /** Get overview info for this tile's z level */
70
- get tileMatrix(): TileMatrix;
67
+ /** Get the level info for this tile's z index. */
68
+ get level(): TilesetLevel;
71
69
  /** Get the children of this node.
72
70
  *
73
71
  * Find all tiles at level this.z + 1 whose spatial extent overlaps this tile.
74
72
  *
75
- * A TileMatrixSet is not a quadtree, but rather a stack of independent grids. We can't cleanly find child tiles by decimation directly.
76
- *
73
+ * A tileset pyramid is not guaranteed to be a quadtree it is a stack of
74
+ * independent grids. We find children by mapping the parent tile's CRS bounds
75
+ * into the child grid using {@link TilesetLevel.crsBoundsToTileRange}.
77
76
  */
78
77
  get children(): RasterTileNode[] | null;
79
78
  /**
80
79
  * Recursively traverse the tile pyramid to determine if this tile (or its
81
80
  * descendants) should be rendered.
82
81
  *
83
- * I.e. Given this tile node, should I render this tile, or should I recurse
84
- * into its children?”
82
+ * I.e. "Given this tile node, should I render this tile, or should I recurse
83
+ * into its children?"
85
84
  *
86
85
  * The algorithm performs:
87
86
  * 1. Visibility culling - reject tiles outside the view frustum
@@ -99,9 +98,9 @@ export declare class RasterTileNode {
99
98
  project: ((xyz: number[]) => number[]) | null;
100
99
  cullingVolume: CullingVolume;
101
100
  elevationBounds: ZRange;
102
- /** Minimum (coarsest) COG overview level */
101
+ /** Minimum (coarsest) overview level */
103
102
  minZ: number;
104
- /** Maximum (finest) COG overview level */
103
+ /** Maximum (finest) overview level */
105
104
  maxZ?: number;
106
105
  /** Optional geographic bounds filter */
107
106
  bounds?: Bounds;
@@ -111,7 +110,7 @@ export declare class RasterTileNode {
111
110
  * Recursively traverses the entire tree and gathers tiles where selected=true.
112
111
  *
113
112
  * @param result - Accumulator array for selected tiles
114
- * @returns Array of selected OSMNode tiles
113
+ * @returns Array of selected RasterTileNode tiles
115
114
  */
116
115
  getSelected(result?: RasterTileNode[]): RasterTileNode[];
117
116
  /**
@@ -141,38 +140,17 @@ export declare class RasterTileNode {
141
140
  private _getGenericBoundingVolume;
142
141
  }
143
142
  /**
144
- * Compute the projected tile bounds in the tile matrix's CRS.
143
+ * Get tile indices visible in viewport.
145
144
  *
146
- * Because it's a linear transformation from the tile index to projected bounds,
147
- * we don't need to sample this for each of the reference points. We only need
148
- * the corners.
145
+ * Uses frustum culling driven by a {@link TilesetDescriptor}, which abstracts
146
+ * over OGC TileMatrixSet grids and Zarr multiscale pyramids.
149
147
  *
150
- * @return The bounding box as [minX, minY, maxX, maxY] in projected CRS.
148
+ * Overview levels follow the descriptor ordering: index 0 = coarsest, higher = finer.
151
149
  */
152
- declare function computeProjectedTileBounds(tileMatrix: TileMatrix, { x, y, }: {
153
- x: number;
154
- y: number;
155
- }): [number, number, number, number];
156
- /**
157
- * Get tile indices visible in viewport
158
- * Uses frustum culling similar to OSM implementation
159
- *
160
- * Overviews follow TileMatrixSet ordering: index 0 = coarsest, higher = finer
161
- */
162
- export declare function getTileIndices(metadata: TileMatrixSet, opts: {
150
+ export declare function getTileIndices(descriptor: TilesetDescriptor, opts: {
163
151
  viewport: Viewport;
164
152
  maxZ: number;
165
153
  zRange: ZRange | null;
166
- projectTo3857: ProjectionFunction;
167
- projectTo4326: ProjectionFunction;
168
- wgs84Bounds: CornerBounds;
154
+ wgs84Bounds: Bounds;
169
155
  }): TileIndex[];
170
- /**
171
- * Exports only for use in testing
172
- */
173
- export declare const __TEST_EXPORTS: {
174
- computeProjectedTileBounds: typeof computeProjectedTileBounds;
175
- RasterTileNode: typeof RasterTileNode;
176
- };
177
- export {};
178
156
  //# sourceMappingURL=raster-tile-traversal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"raster-tile-traversal.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/raster-tile-traversal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,MAAM,EACP,MAAM,YAAY,CAAC;AAqEpB;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACzB,yBAAyB;IACzB,CAAC,EAA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