@developmentseed/deck.gl-raster 0.5.0-beta.1 → 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.
- package/dist/gpu-modules/composite-bands.d.ts +85 -0
- package/dist/gpu-modules/composite-bands.d.ts.map +1 -0
- package/dist/gpu-modules/composite-bands.js +141 -0
- package/dist/gpu-modules/composite-bands.js.map +1 -0
- package/dist/gpu-modules/cutline-bbox.d.ts +70 -0
- package/dist/gpu-modules/cutline-bbox.d.ts.map +1 -0
- package/dist/gpu-modules/cutline-bbox.js +100 -0
- package/dist/gpu-modules/cutline-bbox.js.map +1 -0
- package/dist/gpu-modules/index.d.ts +6 -0
- package/dist/gpu-modules/index.d.ts.map +1 -1
- package/dist/gpu-modules/index.js +3 -0
- package/dist/gpu-modules/index.js.map +1 -1
- package/dist/gpu-modules/linear-rescale.d.ts +39 -0
- package/dist/gpu-modules/linear-rescale.d.ts.map +1 -0
- package/dist/gpu-modules/linear-rescale.js +40 -0
- package/dist/gpu-modules/linear-rescale.js.map +1 -0
- package/dist/gpu-modules/types.d.ts +10 -1
- package/dist/gpu-modules/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/layer-utils.d.ts +28 -0
- package/dist/layer-utils.d.ts.map +1 -0
- package/dist/layer-utils.js +56 -0
- package/dist/layer-utils.js.map +1 -0
- package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
- package/dist/mesh-layer/mesh-layer.js +10 -1
- package/dist/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/multi-raster-tileset/index.d.ts +5 -0
- package/dist/multi-raster-tileset/index.d.ts.map +1 -0
- package/dist/multi-raster-tileset/index.js +3 -0
- package/dist/multi-raster-tileset/index.js.map +1 -0
- package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts +75 -0
- package/dist/multi-raster-tileset/multi-tileset-descriptor.d.ts.map +1 -0
- package/dist/multi-raster-tileset/multi-tileset-descriptor.js +97 -0
- package/dist/multi-raster-tileset/multi-tileset-descriptor.js.map +1 -0
- package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts +129 -0
- package/dist/multi-raster-tileset/secondary-tile-resolver.d.ts.map +1 -0
- package/dist/multi-raster-tileset/secondary-tile-resolver.js +88 -0
- package/dist/multi-raster-tileset/secondary-tile-resolver.js.map +1 -0
- package/dist/raster-tileset/index.d.ts +4 -1
- package/dist/raster-tileset/index.d.ts.map +1 -1
- package/dist/raster-tileset/index.js +2 -1
- package/dist/raster-tileset/index.js.map +1 -1
- package/dist/raster-tileset/raster-tile-traversal.d.ts +29 -51
- package/dist/raster-tileset/raster-tile-traversal.d.ts.map +1 -1
- package/dist/raster-tileset/raster-tile-traversal.js +113 -171
- package/dist/raster-tileset/raster-tile-traversal.js.map +1 -1
- package/dist/raster-tileset/raster-tileset-2d.d.ts +8 -22
- package/dist/raster-tileset/raster-tileset-2d.d.ts.map +1 -1
- package/dist/raster-tileset/raster-tileset-2d.js +18 -81
- package/dist/raster-tileset/raster-tileset-2d.js.map +1 -1
- package/dist/raster-tileset/tile-matrix-set.d.ts +20 -0
- package/dist/raster-tileset/tile-matrix-set.d.ts.map +1 -0
- package/dist/raster-tileset/tile-matrix-set.js +121 -0
- package/dist/raster-tileset/tile-matrix-set.js.map +1 -0
- package/dist/raster-tileset/tileset-interface.d.ts +78 -0
- package/dist/raster-tileset/tileset-interface.d.ts.map +1 -0
- package/dist/raster-tileset/tileset-interface.js +2 -0
- package/dist/raster-tileset/tileset-interface.js.map +1 -0
- package/dist/raster-tileset/types.d.ts +10 -18
- package/dist/raster-tileset/types.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PathLayer, TextLayer } from "@deck.gl/layers";
|
|
2
|
+
export function renderDebugTileOutline(id, tile, forwardTo4326) {
|
|
3
|
+
const { projectedCorners } = tile;
|
|
4
|
+
// Create a closed path in WGS84 projection around the tile bounds
|
|
5
|
+
//
|
|
6
|
+
// The tile has a `bbox` field which is already the bounding box in WGS84,
|
|
7
|
+
// but that uses `transformBounds` and densifies edges. So the corners of
|
|
8
|
+
// the bounding boxes don't line up with each other.
|
|
9
|
+
//
|
|
10
|
+
// In this case in the debug mode, it looks better if we ignore the actual
|
|
11
|
+
// non-linearities of the edges and just draw a box connecting the
|
|
12
|
+
// reprojected corners. In any case, the _image itself_ will be densified
|
|
13
|
+
// on the edges as a feature of the mesh generation.
|
|
14
|
+
const { topLeft, topRight, bottomRight, bottomLeft } = projectedCorners;
|
|
15
|
+
const topLeftWgs84 = forwardTo4326(topLeft[0], topLeft[1]);
|
|
16
|
+
const topRightWgs84 = forwardTo4326(topRight[0], topRight[1]);
|
|
17
|
+
const bottomRightWgs84 = forwardTo4326(bottomRight[0], bottomRight[1]);
|
|
18
|
+
const bottomLeftWgs84 = forwardTo4326(bottomLeft[0], bottomLeft[1]);
|
|
19
|
+
const path = [
|
|
20
|
+
topLeftWgs84,
|
|
21
|
+
topRightWgs84,
|
|
22
|
+
bottomRightWgs84,
|
|
23
|
+
bottomLeftWgs84,
|
|
24
|
+
topLeftWgs84,
|
|
25
|
+
];
|
|
26
|
+
const center = [
|
|
27
|
+
(topLeftWgs84[0] + bottomRightWgs84[0]) / 2,
|
|
28
|
+
(topLeftWgs84[1] + bottomRightWgs84[1]) / 2,
|
|
29
|
+
];
|
|
30
|
+
const labelLayer = new TextLayer({
|
|
31
|
+
id: `${id}-label`,
|
|
32
|
+
data: [
|
|
33
|
+
{
|
|
34
|
+
position: center,
|
|
35
|
+
text: `x=${tile.index.x} y=${tile.index.y} z=${tile.index.z}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
getColor: [255, 255, 255, 255],
|
|
39
|
+
getSize: 24,
|
|
40
|
+
sizeUnits: "pixels",
|
|
41
|
+
outlineWidth: 3,
|
|
42
|
+
outlineColor: [0, 0, 0, 255],
|
|
43
|
+
fontSettings: { sdf: true },
|
|
44
|
+
});
|
|
45
|
+
const outlineLayer = new PathLayer({
|
|
46
|
+
id,
|
|
47
|
+
data: [path],
|
|
48
|
+
getPath: (d) => d,
|
|
49
|
+
getColor: [255, 0, 0, 255], // Red
|
|
50
|
+
getWidth: 2,
|
|
51
|
+
widthUnits: "pixels",
|
|
52
|
+
pickable: false,
|
|
53
|
+
});
|
|
54
|
+
return [outlineLayer, labelLayer];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=layer-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-utils.js","sourceRoot":"","sources":["../src/layer-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIvD,MAAM,UAAU,sBAAsB,CACpC,EAAU,EACV,IAAiC,EACjC,aAAkD;IAElD,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAElC,kEAAkE;IAClE,EAAE;IACF,0EAA0E;IAC1E,yEAAyE;IACzE,oDAAoD;IACpD,EAAE;IACF,0EAA0E;IAC1E,kEAAkE;IAClE,yEAAyE;IACzE,oDAAoD;IACpD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC;IACxE,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,gBAAgB,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,eAAe,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,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Y,EAAE,UAAU,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-layer.d.ts","sourceRoot":"","sources":["../../src/mesh-layer/mesh-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,KAAK,sBAAsB,GACvB;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAA;CAAE,GACzD;IAAE,cAAc,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GACtD,sBAAsB,CAAC;AAEzB,QAAA,MAAM,YAAY,EAAE,YAAY,CAC9B,oBAAoB,GAAG;IACrB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,
|
|
1
|
+
{"version":3,"file":"mesh-layer.d.ts","sourceRoot":"","sources":["../../src/mesh-layer/mesh-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,KAAK,sBAAsB,GACvB;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAA;CAAE,GACzD;IAAE,cAAc,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GACtD,sBAAsB,CAAC;AAEzB,QAAA,MAAM,YAAY,EAAE,YAAY,CAC9B,oBAAoB,GAAG;IACrB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAcF,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,eAAe,CACnD,IAAI,EACJ,qBAAqB,CACtB;IACC,OAAgB,SAAS,SAAwB;IACjD,OAAgB,YAAY,EAAE,OAAO,YAAY,CAAgB;IAEjE,sBAAsB,IAAI,YAAY,EAAE;IAQ/B,UAAU;IAiBV,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;CAa/B"}
|
|
@@ -3,8 +3,17 @@ import { CreateTexture } from "../gpu-modules/create-texture.js";
|
|
|
3
3
|
import fs from "./mesh-layer-fragment.glsl.js";
|
|
4
4
|
const defaultProps = {
|
|
5
5
|
...SimpleMeshLayer.defaultProps,
|
|
6
|
-
|
|
6
|
+
// Note: putting `image` in defaultProps causes Maplibre to fail to render
|
|
7
|
+
// labels in interleaved mode 🤷♂️
|
|
8
|
+
// image: { type: "image", value: null, async: true },
|
|
7
9
|
renderPipeline: { type: "array", value: [], compare: true },
|
|
10
|
+
// Disable lighting by default (avoids darkening raster)
|
|
11
|
+
material: {
|
|
12
|
+
ambient: 1.0,
|
|
13
|
+
diffuse: 0.0,
|
|
14
|
+
shininess: 0,
|
|
15
|
+
specularColor: [0, 0, 0],
|
|
16
|
+
},
|
|
8
17
|
};
|
|
9
18
|
/**
|
|
10
19
|
* A small subclass of the SimpleMeshLayer to allow dynamic shader injections.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-layer.js","sourceRoot":"","sources":["../../src/mesh-layer/mesh-layer.ts"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;QACP,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAEQ,UAAU;QACjB,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;QAE3C,MAAM,OAAO,GAAmB,eAAe,CAAC,OAAO,CAAC;QACxD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,OAAO;YACL,GAAG,eAAe;YAClB,kEAAkE;YAClE,mBAAmB;YACnB,EAAE;YACF,OAAO;SACR,CAAC;IACJ,CAAC;IAEQ,IAAI,CAAC,IAAS;QACrB,MAAM,WAAW,GAAsD,EAAE,CAAC;QAC1E,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;YAC9C,uCAAuC;YACvC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC7C,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YAClC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { MultiTilesetDescriptor, SecondaryLevelStrategy, } from "./multi-tileset-descriptor.js";
|
|
2
|
+
export { createMultiTilesetDescriptor, selectSecondaryLevel, tilesetLevelsEqual, } from "./multi-tileset-descriptor.js";
|
|
3
|
+
export type { SecondaryTileIndex, SecondaryTileResolution, UvTransform, } from "./secondary-tile-resolver.js";
|
|
4
|
+
export { resolveSecondaryTiles } from "./secondary-tile-resolver.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/multi-raster-tileset/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,GACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/multi-raster-tileset/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -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,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;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAA0B,EAC1B,UAAkB,EAClB,UAAkB,EAClB,cAA4B,EAC5B,UAAkB;IAElB,iDAAiD;IACjD,MAAM,OAAO,GAAG,YAAY,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC1E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CACvB,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CACvB,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EACrB,OAAO,CA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AgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,OAAO,GACX,iBAAiB,GAAG,CAAC;QACnB,CAAC,CAAC,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,iBAAiB;QAClD,CAAC,CAAC,CAAC,CAAC;IAER,oCAAoC;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC;IACzD,MAAM,cAAc,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 {
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/raster-tileset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
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"}
|