@developmentseed/deck.gl-raster 0.4.0 → 0.5.0

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 (69) hide show
  1. package/dist/gpu-modules/composite-bands.d.ts +85 -0
  2. package/dist/gpu-modules/composite-bands.d.ts.map +1 -0
  3. package/dist/gpu-modules/composite-bands.js +141 -0
  4. package/dist/gpu-modules/composite-bands.js.map +1 -0
  5. package/dist/gpu-modules/cutline-bbox.d.ts +70 -0
  6. package/dist/gpu-modules/cutline-bbox.d.ts.map +1 -0
  7. package/dist/gpu-modules/cutline-bbox.js +100 -0
  8. package/dist/gpu-modules/cutline-bbox.js.map +1 -0
  9. package/dist/gpu-modules/index.d.ts +6 -0
  10. package/dist/gpu-modules/index.d.ts.map +1 -1
  11. package/dist/gpu-modules/index.js +3 -0
  12. package/dist/gpu-modules/index.js.map +1 -1
  13. package/dist/gpu-modules/linear-rescale.d.ts +39 -0
  14. package/dist/gpu-modules/linear-rescale.d.ts.map +1 -0
  15. package/dist/gpu-modules/linear-rescale.js +40 -0
  16. package/dist/gpu-modules/linear-rescale.js.map +1 -0
  17. package/dist/gpu-modules/types.d.ts +10 -1
  18. package/dist/gpu-modules/types.d.ts.map +1 -1
  19. package/dist/index.d.ts +6 -10
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +4 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/layer-utils.d.ts +28 -0
  24. package/dist/layer-utils.d.ts.map +1 -0
  25. package/dist/layer-utils.js +56 -0
  26. package/dist/layer-utils.js.map +1 -0
  27. package/dist/mesh-layer/mesh-layer.d.ts +15 -3
  28. package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
  29. package/dist/mesh-layer/mesh-layer.js +25 -3
  30. package/dist/mesh-layer/mesh-layer.js.map +1 -1
  31. package/dist/multi-raster-tileset/index.d.ts +5 -0
  32. package/dist/multi-raster-tileset/index.d.ts.map +1 -0
  33. package/dist/multi-raster-tileset/index.js +3 -0
  34. package/dist/multi-raster-tileset/index.js.map +1 -0
  35. package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts +75 -0
  36. package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts.map +1 -0
  37. package/dist/multi-raster-tileset/multi-tileset-descriptor.js +97 -0
  38. package/dist/multi-raster-tileset/multi-tileset-descriptor.js.map +1 -0
  39. package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts +129 -0
  40. package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts.map +1 -0
  41. package/dist/multi-raster-tileset/secondary-tile-resolver.js +88 -0
  42. package/dist/multi-raster-tileset/secondary-tile-resolver.js.map +1 -0
  43. package/dist/raster-layer.d.ts +30 -12
  44. package/dist/raster-layer.d.ts.map +1 -1
  45. package/dist/raster-layer.js +20 -28
  46. package/dist/raster-layer.js.map +1 -1
  47. package/dist/raster-tileset/index.d.ts +4 -1
  48. package/dist/raster-tileset/index.d.ts.map +1 -1
  49. package/dist/raster-tileset/index.js +2 -1
  50. package/dist/raster-tileset/index.js.map +1 -1
  51. package/dist/raster-tileset/raster-tile-traversal.d.ts +35 -51
  52. package/dist/raster-tileset/raster-tile-traversal.d.ts.map +1 -1
  53. package/dist/raster-tileset/raster-tile-traversal.js +128 -172
  54. package/dist/raster-tileset/raster-tile-traversal.js.map +1 -1
  55. package/dist/raster-tileset/raster-tileset-2d.d.ts +8 -22
  56. package/dist/raster-tileset/raster-tileset-2d.d.ts.map +1 -1
  57. package/dist/raster-tileset/raster-tileset-2d.js +18 -81
  58. package/dist/raster-tileset/raster-tileset-2d.js.map +1 -1
  59. package/dist/raster-tileset/tile-matrix-set.d.ts +20 -0
  60. package/dist/raster-tileset/tile-matrix-set.d.ts.map +1 -0
  61. package/dist/raster-tileset/tile-matrix-set.js +121 -0
  62. package/dist/raster-tileset/tile-matrix-set.js.map +1 -0
  63. package/dist/raster-tileset/tileset-interface.d.ts +78 -0
  64. package/dist/raster-tileset/tileset-interface.d.ts.map +1 -0
  65. package/dist/raster-tileset/tileset-interface.js +2 -0
  66. package/dist/raster-tileset/tileset-interface.js.map +1 -0
  67. package/dist/raster-tileset/types.d.ts +10 -18
  68. package/dist/raster-tileset/types.d.ts.map +1 -1
  69. package/package.json +14 -14
@@ -1,12 +1,11 @@
1
1
  /**
2
- * TileMatrixSetTileset - Improved Implementation with Frustum Culling
2
+ * RasterTileset2D - Generic tile traversal over a tile pyramid with Frustum
3
+ * Culling
3
4
  *
4
5
  * This version properly implements frustum culling and bounding volume calculations
5
6
  * following the pattern from deck.gl's OSM tile indexing.
6
7
  */
7
8
  import { _Tileset2D as Tileset2D } from "@deck.gl/geo-layers";
8
- import * as affine from "@developmentseed/affine";
9
- import { tileTransform } from "@developmentseed/morecantile";
10
9
  import { transformBounds } from "@developmentseed/proj";
11
10
  import { getTileIndices } from "./raster-tile-traversal";
12
11
  /**
@@ -16,22 +15,15 @@ import { getTileIndices } from "./raster-tile-traversal";
16
15
  *
17
16
  * Handles tile lifecycle, caching, and viewport-based loading.
18
17
  */
19
- export class TileMatrixSetTileset extends Tileset2D {
20
- tms;
18
+ export class RasterTileset2D extends Tileset2D {
19
+ descriptor;
21
20
  wgs84Bounds;
22
- projectTo3857;
23
21
  projectTo4326;
24
- constructor(opts, tms, { projectTo4326, projectTo3857, }) {
22
+ constructor(opts, descriptor, { projectTo4326, }) {
25
23
  super(opts);
26
- this.tms = tms;
27
- this.projectTo3857 = projectTo3857;
24
+ this.descriptor = descriptor;
28
25
  this.projectTo4326 = projectTo4326;
29
- if (!tms.boundingBox) {
30
- throw new Error("Bounding Box inference not yet implemented; should be provided on TileMatrixSet");
31
- }
32
- this.wgs84Bounds = projectBoundsToWgs84(tms.boundingBox, projectTo4326, {
33
- densifyPts: 10,
34
- });
26
+ this.wgs84Bounds = transformBounds(projectTo4326, ...this.descriptor.projectedBounds);
35
27
  }
36
28
  /**
37
29
  * Get tile indices visible in viewport
@@ -40,17 +32,15 @@ export class TileMatrixSetTileset extends Tileset2D {
40
32
  * Overviews follow TileMatrixSet ordering: index 0 = coarsest, higher = finer
41
33
  */
42
34
  getTileIndices(opts) {
43
- const maxAvailableZ = this.tms.tileMatrices.length - 1;
35
+ const maxAvailableZ = this.descriptor.levels.length - 1;
44
36
  const maxZ = typeof opts.maxZoom === "number"
45
37
  ? Math.min(opts.maxZoom, maxAvailableZ)
46
38
  : maxAvailableZ;
47
- const tileIndices = getTileIndices(this.tms, {
39
+ const tileIndices = getTileIndices(this.descriptor, {
48
40
  viewport: opts.viewport,
49
41
  maxZ,
50
42
  zRange: opts.zRange ?? null,
51
43
  wgs84Bounds: this.wgs84Bounds,
52
- projectTo3857: this.projectTo3857,
53
- projectTo4326: this.projectTo4326,
54
44
  });
55
45
  return tileIndices;
56
46
  }
@@ -62,17 +52,17 @@ export class TileMatrixSetTileset extends Tileset2D {
62
52
  // Already at coarsest level
63
53
  return index;
64
54
  }
65
- const currentOverview = this.tms.tileMatrices[index.z];
66
- const parentOverview = this.tms.tileMatrices[index.z - 1];
55
+ const currentOverview = this.descriptor.levels[index.z];
56
+ const parentOverview = this.descriptor.levels[index.z - 1];
67
57
  // Decimation is the number of child tiles that fit across one parent tile.
68
58
  // Must use tile footprint (cellSize × tileWidth/Height), not cellSize alone,
69
59
  // because tileWidth can change between levels (e.g. the last Sentinel-2
70
60
  // overview doubles tileWidth while halving cellSize, giving a 1:1 spatial
71
61
  // mapping where decimation = 1).
72
- const parentFootprintX = parentOverview.cellSize * parentOverview.tileWidth;
73
- const parentFootprintY = parentOverview.cellSize * parentOverview.tileHeight;
74
- const currentFootprintX = currentOverview.cellSize * currentOverview.tileWidth;
75
- const currentFootprintY = currentOverview.cellSize * currentOverview.tileHeight;
62
+ const parentFootprintX = parentOverview.metersPerPixel * parentOverview.tileWidth;
63
+ const parentFootprintY = parentOverview.metersPerPixel * parentOverview.tileHeight;
64
+ const currentFootprintX = currentOverview.metersPerPixel * currentOverview.tileWidth;
65
+ const currentFootprintY = currentOverview.metersPerPixel * currentOverview.tileHeight;
76
66
  const decimationX = parentFootprintX / currentFootprintX;
77
67
  const decimationY = parentFootprintY / currentFootprintY;
78
68
  return {
@@ -86,16 +76,9 @@ export class TileMatrixSetTileset extends Tileset2D {
86
76
  }
87
77
  getTileMetadata(index) {
88
78
  const { x, y, z } = index;
89
- const { tileMatrices } = this.tms;
90
- const tileMatrix = tileMatrices[z];
91
- const { tileHeight, tileWidth } = tileMatrix;
92
- const tileAffine = tileTransform(tileMatrix, { col: x, row: y });
93
- // tileAffine maps pixel (0,0) → top-left corner of this tile, so use
94
- // local pixel coordinates (0..tileWidth, 0..tileHeight).
95
- const topLeft = affine.apply(tileAffine, 0, 0);
96
- const topRight = affine.apply(tileAffine, tileWidth, 0);
97
- const bottomLeft = affine.apply(tileAffine, 0, tileHeight);
98
- const bottomRight = affine.apply(tileAffine, tileWidth, tileHeight);
79
+ const levelDescriptor = this.descriptor.levels[z];
80
+ const { tileHeight, tileWidth } = levelDescriptor;
81
+ const { topLeft, topRight, bottomLeft, bottomRight } = levelDescriptor.projectedTileCorners(x, y);
99
82
  // Return the projected bounds as four corners
100
83
  // This preserves rotation/skew information
101
84
  const projectedCorners = {
@@ -132,53 +115,7 @@ export class TileMatrixSetTileset extends Tileset2D {
132
115
  projectedCorners,
133
116
  tileWidth,
134
117
  tileHeight,
135
- tileMatrix,
136
118
  };
137
119
  }
138
120
  }
139
- function projectBoundsToWgs84(bounds, projectTo4326, { densifyPts }) {
140
- const { lowerLeft, upperRight } = bounds;
141
- // Four corners of the bounding box
142
- const corners = [
143
- lowerLeft,
144
- [upperRight[0], lowerLeft[1]],
145
- upperRight,
146
- [lowerLeft[0], upperRight[1]],
147
- ];
148
- // Densify edges: interpolate densifyPts points along each edge
149
- const points = [];
150
- for (let i = 0; i < corners.length; i++) {
151
- const from = corners[i];
152
- const to = corners[(i + 1) % corners.length];
153
- // Include the start corner and all intermediate points (end corner
154
- // will be included as the start of the next edge)
155
- for (let j = 0; j <= densifyPts; j++) {
156
- const t = j / (densifyPts + 1);
157
- points.push([
158
- from[0] + (to[0] - from[0]) * t,
159
- from[1] + (to[1] - from[1]) * t,
160
- ]);
161
- }
162
- }
163
- // Reproject all points to WGS84 and compute the bounding box
164
- let wgsMinX = Infinity;
165
- let wgsMinY = Infinity;
166
- let wgsMaxX = -Infinity;
167
- let wgsMaxY = -Infinity;
168
- for (const [x, y] of points) {
169
- const [lon, lat] = projectTo4326(x, y);
170
- if (lon < wgsMinX)
171
- wgsMinX = lon;
172
- if (lat < wgsMinY)
173
- wgsMinY = lat;
174
- if (lon > wgsMaxX)
175
- wgsMaxX = lon;
176
- if (lat > wgsMaxY)
177
- wgsMaxY = lat;
178
- }
179
- return {
180
- lowerLeft: [wgsMinX, wgsMinY],
181
- upperRight: [wgsMaxX, wgsMaxY],
182
- };
183
- }
184
121
  //# sourceMappingURL=raster-tileset-2d.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"raster-tileset-2d.js","sourceRoot":"","sources":["../../src/raster-tileset/raster-tileset-2d.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAMlD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAyDzD;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACzC,GAAG,CAAgB;IACnB,WAAW,CAAe;IAC1B,aAAa,CAAqB;IAClC,aAAa,CAAqB;IAE1C,YACE,IAAoB,EACpB,GAAkB,EAClB,EACE,aAAa,EACb,aAAa,GAId;QAED,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,aAAa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,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,eAAe,CAChD,IAAI,CAAC,aAAa,EAClB,GAAG,eAAe,CACnB,CAAC;QAEF,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI;gBACJ,KAAK;gBACL,IAAI;gBACJ,KAAK;aACN;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;gBACxB,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;gBAC1B,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;gBACzB,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;aACxB;YACD,gBAAgB;YAChB,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { TileMatrixSet } from "@developmentseed/morecantile";
2
+ import type { TilesetDescriptor, TilesetLevel } from "./tileset-interface";
3
+ import type { Bounds, ProjectionFunction } from "./types";
4
+ /**
5
+ * An adapter interface to use a TileMatrixSet as a TilesetDescriptor for raster
6
+ * tile traversal.
7
+ */
8
+ export declare class TileMatrixSetAdaptor implements TilesetDescriptor {
9
+ tms: TileMatrixSet;
10
+ private _levels;
11
+ projectTo3857: ProjectionFunction;
12
+ projectTo4326: ProjectionFunction;
13
+ constructor(tms: TileMatrixSet, { projectTo3857, projectTo4326, }: {
14
+ projectTo3857: ProjectionFunction;
15
+ projectTo4326: ProjectionFunction;
16
+ });
17
+ get levels(): TilesetLevel[];
18
+ get projectedBounds(): Bounds;
19
+ }
20
+ //# sourceMappingURL=tile-matrix-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-matrix-set.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/tile-matrix-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAW,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0HnE;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAC5D,GAAG,EAAE,aAAa,CAAC;IACnB,OAAO,CAAC,OAAO,CAAsB;IACrC,aAAa,EAAE,kBAAkB,CAAC;IAClC,aAAa,EAAE,kBAAkB,CAAC;gBAGhC,GAAG,EAAE,aAAa,EAClB,EACE,aAAa,EACb,aAAa,GACd,EAAE;QAAE,aAAa,EAAE,kBAAkB,CAAC;QAAC,aAAa,EAAE,kBAAkB,CAAA;KAAE;IAQ7E,IAAI,MAAM,IAAI,YAAY,EAAE,CAE3B;IAED,IAAI,eAAe,IAAI,MAAM,CAU5B;CACF"}
@@ -0,0 +1,121 @@
1
+ import { xy_bounds } from "@developmentseed/morecantile";
2
+ // 0.28 mm per pixel — OGC TMS 2.0 standard screen pixel size
3
+ // https://docs.ogc.org/is/17-083r4/17-083r4.html#toc15
4
+ const SCREEN_PIXEL_SIZE = 0.00028;
5
+ class TileMatrixAdaptor {
6
+ inner;
7
+ constructor(tileMatrix) {
8
+ this.inner = tileMatrix;
9
+ }
10
+ get matrixWidth() {
11
+ return this.inner.matrixWidth;
12
+ }
13
+ get matrixHeight() {
14
+ return this.inner.matrixHeight;
15
+ }
16
+ get tileWidth() {
17
+ return this.inner.tileWidth;
18
+ }
19
+ get tileHeight() {
20
+ return this.inner.tileHeight;
21
+ }
22
+ get metersPerPixel() {
23
+ return this.inner.scaleDenominator * SCREEN_PIXEL_SIZE;
24
+ }
25
+ /**
26
+ * Compute the projected tile bounds in the tile matrix's CRS.
27
+ *
28
+ * Because it's a linear transformation from the tile index to projected bounds,
29
+ * we don't need to sample this for each of the reference points. We only need
30
+ * the corners.
31
+ *
32
+ * @return The bounding box as [minX, minY, maxX, maxY] in projected CRS.
33
+ */
34
+ projectedTileCorners(col, row) {
35
+ const bounds = xy_bounds(this.inner, { x: col, y: row });
36
+ return {
37
+ topLeft: [bounds.lowerLeft[0], bounds.upperRight[1]],
38
+ topRight: bounds.upperRight,
39
+ bottomLeft: bounds.lowerLeft,
40
+ bottomRight: [bounds.upperRight[0], bounds.lowerLeft[1]],
41
+ };
42
+ }
43
+ /**
44
+ * Compute the range of tile indices in a child TileMatrix that spatially
45
+ * overlap a parent tile
46
+ *
47
+ * TileMatrixSets are not guaranteed to form a strict quadtree: successive
48
+ * TileMatrix levels may differ by non-integer refinement ratios and may not
49
+ * align perfectly in tile space. As a result, parent/child relationships
50
+ * cannot be inferred from zoom level or resolution alone.
51
+ *
52
+ * This function determines parent→child relationships by:
53
+ * 1. Treating each TileMatrix as an independent, axis-aligned grid in CRS space
54
+ * 2. Mapping the parent tile's CRS bounding box into the child grid
55
+ * 3. Returning the inclusive range of child tile indices whose spatial extent
56
+ * intersects the parent tile
57
+ *
58
+ * The returned indices are clamped to the valid extents of the child matrix
59
+ * (`[0, matrixWidth)` and `[0, matrixHeight)`).
60
+ *
61
+ * Assumptions:
62
+ * - The TileMatrix grid is axis-aligned in CRS space
63
+ * - `cornerOfOrigin` is `"topLeft"`
64
+ * - Tiles are rectangular and uniformly sized within a TileMatrix
65
+ *
66
+ * @param parentBounds Bounding box of the parent tile in CRS coordinates
67
+ * as `[minX, minY, maxX, maxY]`
68
+ * @param childMatrix The TileMatrix definition for the child zoom level
69
+ *
70
+ * @returns An object containing inclusive index ranges:
71
+ * `{ minCol, maxCol, minRow, maxRow }`, identifying all child tiles
72
+ * that spatially overlap the parent tile
73
+ */
74
+ crsBoundsToTileRange(projectedMinX, projectedMinY, projectedMaxX, projectedMaxY) {
75
+ const { tileWidth, tileHeight, cellSize, matrixWidth, matrixHeight, pointOfOrigin, } = this.inner;
76
+ const childTileWidthCRS = tileWidth * cellSize;
77
+ const childTileHeightCRS = tileHeight * cellSize;
78
+ // Note: we assume top left origin
79
+ const originX = pointOfOrigin[0];
80
+ const originY = pointOfOrigin[1];
81
+ // Convert CRS bounds → tile indices
82
+ let minCol = Math.floor((projectedMinX - originX) / childTileWidthCRS);
83
+ let maxCol = Math.floor((projectedMaxX - originX) / childTileWidthCRS);
84
+ let minRow = Math.floor((originY - projectedMaxY) / childTileHeightCRS);
85
+ let maxRow = Math.floor((originY - projectedMinY) / childTileHeightCRS);
86
+ // Clamp to matrix bounds
87
+ minCol = Math.max(0, Math.min(matrixWidth - 1, minCol));
88
+ maxCol = Math.max(0, Math.min(matrixWidth - 1, maxCol));
89
+ minRow = Math.max(0, Math.min(matrixHeight - 1, minRow));
90
+ maxRow = Math.max(0, Math.min(matrixHeight - 1, maxRow));
91
+ return { minCol, maxCol, minRow, maxRow };
92
+ }
93
+ }
94
+ /**
95
+ * An adapter interface to use a TileMatrixSet as a TilesetDescriptor for raster
96
+ * tile traversal.
97
+ */
98
+ export class TileMatrixSetAdaptor {
99
+ tms;
100
+ _levels;
101
+ projectTo3857;
102
+ projectTo4326;
103
+ constructor(tms, { projectTo3857, projectTo4326, }) {
104
+ this.tms = tms;
105
+ this._levels = tms.tileMatrices.map((tm) => new TileMatrixAdaptor(tm));
106
+ this.projectTo3857 = projectTo3857;
107
+ this.projectTo4326 = projectTo4326;
108
+ }
109
+ get levels() {
110
+ return this._levels;
111
+ }
112
+ get projectedBounds() {
113
+ const { boundingBox } = this.tms;
114
+ if (!boundingBox) {
115
+ throw new Error("Bounding Box inference not yet implemented; should be provided on TileMatrixSet");
116
+ }
117
+ const { lowerLeft, upperRight } = boundingBox;
118
+ return [lowerLeft[0], lowerLeft[1], upperRight[0], upperRight[1]];
119
+ }
120
+ }
121
+ //# sourceMappingURL=tile-matrix-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-matrix-set.js","sourceRoot":"","sources":["../../src/raster-tileset/tile-matrix-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIzD,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC,M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AM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAC/B,GAAG,CAAgB;IACX,OAAO,CAAsB;IACrC,aAAa,CAAqB;IAClC,aAAa,CAAqB;IAElC,YACE,GAAkB,EAClB,EACE,aAAa,EACb,aAAa,GAC4D;QAE3E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,eAAe;QACjB,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QACjC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;QAC9C,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,78 @@
1
+ import type { Bounds, Corners, ProjectionFunction } from "./types.js";
2
+ /**
3
+ * A single zoom level in a generic raster tileset.
4
+ *
5
+ * This interface abstracts over both TileMatrixSet levels and Zarr multiscale
6
+ * levels, enabling a single traversal algorithm to work with both.
7
+ */
8
+ export interface TilesetLevel {
9
+ /** Number of tiles across this level (columns). */
10
+ matrixWidth: number;
11
+ /** Number of tiles down this level (rows). */
12
+ matrixHeight: number;
13
+ /** Width of each tile in pixels. */
14
+ tileWidth: number;
15
+ /** Height of each tile in pixels. */
16
+ tileHeight: number;
17
+ /**
18
+ * Meters per pixel — used for LOD selection.
19
+ *
20
+ * For TileMatrix: `scaleDenominator * SCREEN_PIXEL_SIZE` (0.00028 m).
21
+ * For Zarr: `sqrt(|scaleX * scaleY|) * mpu` (meters per CRS unit).
22
+ */
23
+ metersPerPixel: number;
24
+ /**
25
+ * Get the projected bounding box of a tile in the source CRS.
26
+ *
27
+ * The tileset is not guaranteed to be axis aligned, so this returns a rotated
28
+ * rectangle as four corners, which preserves rotation/skew information that
29
+ * would be lost in an axis-aligned bbox.
30
+ *
31
+ * For TMS this delegates to `xy_bounds()`; for Zarr it uses affine math
32
+ * directly. Using a function (rather than a stored affine) lets TMS handle
33
+ * variable tile widths (coalesced rows) and bottomLeft origins cleanly.
34
+ */
35
+ projectedTileCorners: (col: number, row: number) => Corners;
36
+ /**
37
+ * Get the range of tile indices that overlap a given CRS bounding box.
38
+ *
39
+ * The returned range is **inclusive** on both ends: a consumer should
40
+ * iterate `for (let col = minCol; col <= maxCol; col++)`.
41
+ *
42
+ * Used by the traversal algorithm to find child tiles from a parent tile's
43
+ * projected bounds.
44
+ */
45
+ crsBoundsToTileRange: (projectedMinX: number, projectedMinY: number, projectedMaxX: number, projectedMaxY: number) => {
46
+ minCol: number;
47
+ maxCol: number;
48
+ minRow: number;
49
+ maxRow: number;
50
+ };
51
+ }
52
+ /**
53
+ * A full multi-resolution raster tileset descriptor.
54
+ *
55
+ * Index 0 = coarsest level, higher index = finer detail (same ordering as
56
+ * TileMatrixSet).
57
+ */
58
+ export interface TilesetDescriptor {
59
+ /** Ordered levels from coarsest (0) to finest. */
60
+ levels: TilesetLevel[];
61
+ /**
62
+ * Projection function from the source CRS → EPSG:3857.
63
+ *
64
+ * Provided by the caller (e.g. COGLayer or ZarrLayer) so that
65
+ * `deck.gl-raster` itself does not need a proj4 dependency.
66
+ */
67
+ projectTo3857: ProjectionFunction;
68
+ /**
69
+ * Projection function from the source CRS → EPSG:4326.
70
+ *
71
+ * Provided by the caller so that `deck.gl-raster` itself does not need a
72
+ * proj4 dependency.
73
+ */
74
+ projectTo4326: ProjectionFunction;
75
+ /** Bounding box of the dataset in the source CRS. */
76
+ projectedBounds: Bounds;
77
+ }
78
+ //# sourceMappingURL=tileset-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileset-interface.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/tileset-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IAEpB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IAErB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAElB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,oBAAoB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5D;;;;;;;;OAQG;IACH,oBAAoB,EAAE,CACpB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,KAClB;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,MAAM,EAAE,YAAY,EAAE,CAAC;IAEvB;;;;;OAKG;IACH,aAAa,EAAE,kBAAkB,CAAC;IAElC;;;;;OAKG;IACH,aAAa,EAAE,kBAAkB,CAAC;IAElC,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tileset-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileset-interface.js","sourceRoot":"","sources":["../../src/raster-tileset/tileset-interface.ts"],"names":[],"mappings":""}
@@ -1,5 +1,13 @@
1
1
  export type ZRange = [minZ: number, maxZ: number];
2
+ /** An axis-aligned bounding box */
2
3
  export type Bounds = [minX: number, minY: number, maxX: number, maxY: number];
4
+ /** Corners which may or may not be axis-aligned. */
5
+ export type Corners = {
6
+ topLeft: Point;
7
+ topRight: Point;
8
+ bottomLeft: Point;
9
+ bottomRight: Point;
10
+ };
3
11
  export type GeoBoundingBox = {
4
12
  west: number;
5
13
  north: number;
@@ -12,18 +20,9 @@ export type ProjectedBoundingBox = {
12
20
  right: number;
13
21
  bottom: number;
14
22
  };
15
- export type TileBoundingBox = ProjectedBoundingBox | GeoBoundingBox;
16
- export type TileLoadProps = {
17
- index: TileIndex;
18
- id: string;
19
- bbox: TileBoundingBox;
20
- url?: string | null;
21
- signal?: AbortSignal;
22
- userData?: Record<string, any>;
23
- zoom?: number;
24
- };
23
+ /** A 2D point represented as [x, y] */
25
24
  export type Point = [number, number];
26
- type CRS = any;
25
+ /** A function that projects coordinates from one CRS to another */
27
26
  export type ProjectionFunction = (x: number, y: number) => Point;
28
27
  /**
29
28
  * Bounding box defined by two named corners
@@ -32,12 +31,6 @@ export type CornerBounds = {
32
31
  lowerLeft: Point;
33
32
  upperRight: Point;
34
33
  };
35
- /**
36
- * Minimum bounding rectangle surrounding a 2D resource in the CRS indicated elsewhere
37
- */
38
- export type TileMatrixSetBoundingBox = CornerBounds & {
39
- crs?: CRS;
40
- };
41
34
  /**
42
35
  * Raster Tile Index
43
36
  *
@@ -54,5 +47,4 @@ export type TileIndex = {
54
47
  */
55
48
  z: number;
56
49
  };
57
- export {};
58
50
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/raster-tileset/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAE9E,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,cAAc,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,eAAe,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,KAAK,GAAG,GAAG,GAAG,CAAC;AAEf,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,E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,uCAAuC;AACvC,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,KAAK,CAAC;IACjB,UAAU,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;CACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developmentseed/deck.gl-raster",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Georeferenced image data visualization in deck.gl",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,29 +37,29 @@
37
37
  "url": "git+https://github.com/developmentseed/deck.gl-raster.git"
38
38
  },
39
39
  "devDependencies": {
40
- "@luma.gl/core": "9.2.6",
41
- "@luma.gl/shadertools": "9.2.6",
40
+ "@luma.gl/core": "9.3.2",
41
+ "@luma.gl/shadertools": "9.3.2",
42
42
  "@types/node": "^25.3.3",
43
43
  "jsdom": "^28.1.0",
44
- "typescript": "^5.9.3",
44
+ "typescript": "^6.0.2",
45
45
  "vitest": "^4.0.18"
46
46
  },
47
47
  "peerDependencies": {
48
- "@deck.gl/core": "^9.2.7",
49
- "@deck.gl/geo-layers": "^9.2.7",
50
- "@deck.gl/layers": "^9.2.7",
51
- "@deck.gl/mesh-layers": "^9.2.7",
52
- "@luma.gl/core": "^9.2.6",
53
- "@luma.gl/shadertools": "^9.2.6"
48
+ "@deck.gl/core": "^9.3.0",
49
+ "@deck.gl/geo-layers": "^9.3.0",
50
+ "@deck.gl/layers": "^9.3.0",
51
+ "@deck.gl/mesh-layers": "^9.3.0",
52
+ "@luma.gl/core": "^9.3.2",
53
+ "@luma.gl/shadertools": "^9.3.2",
54
+ "@developmentseed/morecantile": "^0.5.0"
54
55
  },
55
56
  "dependencies": {
56
57
  "@math.gl/core": "^4.1.0",
57
58
  "@math.gl/culling": "^4.1.0",
58
59
  "@math.gl/web-mercator": "^4.1.0",
59
- "@developmentseed/affine": "^0.4.0",
60
- "@developmentseed/morecantile": "^0.4.0",
61
- "@developmentseed/raster-reproject": "^0.4.0",
62
- "@developmentseed/proj": "^0.4.0"
60
+ "@developmentseed/affine": "^0.5.0",
61
+ "@developmentseed/proj": "^0.5.0",
62
+ "@developmentseed/raster-reproject": "^0.5.0"
63
63
  },
64
64
  "volta": {
65
65
  "extends": "../../package.json"