@developmentseed/deck.gl-geotiff 0.1.0-beta.4
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/README.md +6 -0
- package/dist/cog-layer.d.ts +53 -0
- package/dist/cog-layer.d.ts.map +1 -0
- package/dist/cog-layer.js +178 -0
- package/dist/cog-layer.js.map +1 -0
- package/dist/cog-tile-matrix-set.d.ts +11 -0
- package/dist/cog-tile-matrix-set.d.ts.map +1 -0
- package/dist/cog-tile-matrix-set.js +179 -0
- package/dist/cog-tile-matrix-set.js.map +1 -0
- package/dist/ellipsoids.d.ts +153 -0
- package/dist/ellipsoids.d.ts.map +1 -0
- package/dist/ellipsoids.js +153 -0
- package/dist/ellipsoids.js.map +1 -0
- package/dist/geotiff-layer.d.ts +55 -0
- package/dist/geotiff-layer.d.ts.map +1 -0
- package/dist/geotiff-layer.js +64 -0
- package/dist/geotiff-layer.js.map +1 -0
- package/dist/geotiff-reprojection.d.ts +31 -0
- package/dist/geotiff-reprojection.d.ts.map +1 -0
- package/dist/geotiff-reprojection.js +172 -0
- package/dist/geotiff-reprojection.js.map +1 -0
- package/dist/geotiff.d.ts +31 -0
- package/dist/geotiff.d.ts.map +1 -0
- package/dist/geotiff.js +70 -0
- package/dist/geotiff.js.map +1 -0
- package/dist/index.cjs +181 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/pool.d.ts +1 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +2 -0
- package/dist/pool.js.map +1 -0
- package/dist/src/geotiff-reprojection.d.ts +10 -0
- package/dist/src/geotiff-reprojection.d.ts.map +1 -0
- package/dist/src/geotiff-reprojection.js +159 -0
- package/dist/src/geotiff-reprojection.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/tests/placeholder.test.d.ts +2 -0
- package/dist/tests/placeholder.test.d.ts.map +1 -0
- package/dist/tests/placeholder.test.js +7 -0
- package/dist/tests/placeholder.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
GeoTIFF and Cloud-Optimized GeoTIFF visualization in deck.gl.
|
|
2
|
+
|
|
3
|
+
There are two layers exported:
|
|
4
|
+
|
|
5
|
+
- `COGLayer` uses a `TileLayer` to individually render each internal tile of a COG. This relies on the input geotiff being tiled and having overviews.
|
|
6
|
+
- `GeoTIFFLayer` **doesn't use a `TileLayer`**. It just fetches the highest resolution image of a `GeoTIFF` and renders it using a `RasterLayer`. This should work for more generic GeoTIFF images, including those that don't have overviews and those that are laid out in strips instead of in tiles.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CompositeLayerProps, UpdateParameters } from "@deck.gl/core";
|
|
2
|
+
import { CompositeLayer } from "@deck.gl/core";
|
|
3
|
+
import { TileLayer } from "@deck.gl/geo-layers";
|
|
4
|
+
import type { TileMatrixSet } from "@developmentseed/deck.gl-raster";
|
|
5
|
+
import type { ReprojectionFns } from "@developmentseed/raster-reproject";
|
|
6
|
+
import type { GeoTIFF, GeoTIFFImage, Pool } from "geotiff";
|
|
7
|
+
export interface COGLayerProps extends CompositeLayerProps {
|
|
8
|
+
geotiff: GeoTIFF;
|
|
9
|
+
/**
|
|
10
|
+
* GeoTIFF.js Pool for decoding image chunks.
|
|
11
|
+
*
|
|
12
|
+
* If none is provided, a default Pool will be created and shared between all
|
|
13
|
+
* COGLayer and GeoTIFFLayer instances.
|
|
14
|
+
*/
|
|
15
|
+
pool?: Pool;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum reprojection error in pixels for mesh refinement.
|
|
18
|
+
* Lower values create denser meshes with higher accuracy.
|
|
19
|
+
* @default 0.125
|
|
20
|
+
*/
|
|
21
|
+
maxError?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Enable debug visualization showing the triangulation mesh
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Opacity of the debug mesh overlay (0-1)
|
|
29
|
+
* @default 0.5
|
|
30
|
+
*/
|
|
31
|
+
debugOpacity?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* COGLayer renders a COG using a tiled approach with reprojection.
|
|
35
|
+
*/
|
|
36
|
+
export declare class COGLayer extends CompositeLayer<COGLayerProps> {
|
|
37
|
+
static layerName: string;
|
|
38
|
+
static defaultProps: {
|
|
39
|
+
maxError: number;
|
|
40
|
+
};
|
|
41
|
+
state: {
|
|
42
|
+
forwardReproject?: ReprojectionFns["forwardReproject"];
|
|
43
|
+
inverseReproject?: ReprojectionFns["inverseReproject"];
|
|
44
|
+
metadata?: TileMatrixSet;
|
|
45
|
+
images?: GeoTIFFImage[];
|
|
46
|
+
};
|
|
47
|
+
initializeState(): void;
|
|
48
|
+
updateState(params: UpdateParameters<this>): void;
|
|
49
|
+
_parseGeoTIFF(): Promise<void>;
|
|
50
|
+
renderTileLayer(metadata: TileMatrixSet, forwardReproject: ReprojectionFns["forwardReproject"], inverseReproject: ReprojectionFns["inverseReproject"], images: GeoTIFFImage[]): TileLayer;
|
|
51
|
+
renderLayers(): TileLayer<any, {}> | null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=cog-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cog-layer.d.ts","sourceRoot":"","sources":["../src/cog-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGh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/geo-layers";
|
|
3
|
+
import { PathLayer } from "@deck.gl/layers";
|
|
4
|
+
import { RasterLayer, RasterTileset2D } from "@developmentseed/deck.gl-raster";
|
|
5
|
+
import proj4 from "proj4";
|
|
6
|
+
import { parseCOGTileMatrixSet } from "./cog-tile-matrix-set.js";
|
|
7
|
+
import { fromGeoTransform, getGeoTIFFProjection, } from "./geotiff-reprojection.js";
|
|
8
|
+
import { defaultPool, loadRgbImage } from "./geotiff.js";
|
|
9
|
+
const DEFAULT_MAX_ERROR = 0.125;
|
|
10
|
+
const defaultProps = {
|
|
11
|
+
maxError: DEFAULT_MAX_ERROR,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* COGLayer renders a COG using a tiled approach with reprojection.
|
|
15
|
+
*/
|
|
16
|
+
export class COGLayer extends CompositeLayer {
|
|
17
|
+
static layerName = "COGLayer";
|
|
18
|
+
static defaultProps = defaultProps;
|
|
19
|
+
initializeState() {
|
|
20
|
+
this.setState({});
|
|
21
|
+
}
|
|
22
|
+
updateState(params) {
|
|
23
|
+
super.updateState(params);
|
|
24
|
+
const { props, oldProps, changeFlags } = params;
|
|
25
|
+
const needsUpdate = Boolean(changeFlags.dataChanged) || props.geotiff !== oldProps.geotiff;
|
|
26
|
+
if (needsUpdate) {
|
|
27
|
+
this._parseGeoTIFF();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async _parseGeoTIFF() {
|
|
31
|
+
const { geotiff } = this.props;
|
|
32
|
+
const metadata = await parseCOGTileMatrixSet(geotiff);
|
|
33
|
+
const image = await geotiff.getImage();
|
|
34
|
+
const imageCount = await geotiff.getImageCount();
|
|
35
|
+
const images = [];
|
|
36
|
+
for (let imageIdx = 0; imageIdx < imageCount; imageIdx++) {
|
|
37
|
+
images.push(await geotiff.getImage(imageIdx));
|
|
38
|
+
}
|
|
39
|
+
const sourceProjection = await getGeoTIFFProjection(image);
|
|
40
|
+
if (!sourceProjection) {
|
|
41
|
+
throw new Error("Could not determine source projection from GeoTIFF geo keys");
|
|
42
|
+
}
|
|
43
|
+
const converter = proj4(sourceProjection, "EPSG:4326");
|
|
44
|
+
const forwardReproject = (x, y) => converter.forward([x, y], false);
|
|
45
|
+
const inverseReproject = (x, y) => converter.inverse([x, y], false);
|
|
46
|
+
this.setState({
|
|
47
|
+
metadata,
|
|
48
|
+
forwardReproject,
|
|
49
|
+
inverseReproject,
|
|
50
|
+
images,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
renderTileLayer(metadata, forwardReproject, inverseReproject, images) {
|
|
54
|
+
const { maxError, debug = false, debugOpacity = 0.5 } = this.props;
|
|
55
|
+
// Create a factory class that wraps COGTileset2D with the metadata
|
|
56
|
+
class RasterTileset2DFactory extends RasterTileset2D {
|
|
57
|
+
constructor(opts) {
|
|
58
|
+
super(metadata, opts);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return new TileLayer({
|
|
62
|
+
id: `cog-tile-layer-${this.id}`,
|
|
63
|
+
TilesetClass: RasterTileset2DFactory,
|
|
64
|
+
getTileData: async (tile) => {
|
|
65
|
+
const { signal } = tile;
|
|
66
|
+
const { x, y, z } = tile.index;
|
|
67
|
+
// Select overview image
|
|
68
|
+
const geotiffImage = images[images.length - 1 - z];
|
|
69
|
+
const imageHeight = geotiffImage.getHeight();
|
|
70
|
+
const imageWidth = geotiffImage.getWidth();
|
|
71
|
+
const tileMatrix = metadata.tileMatrices[z];
|
|
72
|
+
const { tileWidth, tileHeight } = tileMatrix;
|
|
73
|
+
const tileGeotransform = computeTileGeotransform(x, y, tileMatrix);
|
|
74
|
+
const { pixelToInputCRS, inputCRSToPixel } = fromGeoTransform(tileGeotransform);
|
|
75
|
+
const window = [
|
|
76
|
+
x * tileWidth,
|
|
77
|
+
y * tileHeight,
|
|
78
|
+
Math.min((x + 1) * tileWidth, imageWidth),
|
|
79
|
+
Math.min((y + 1) * tileHeight, imageHeight),
|
|
80
|
+
];
|
|
81
|
+
const { imageData, height, width } = await loadRgbImage(geotiffImage, {
|
|
82
|
+
window,
|
|
83
|
+
signal,
|
|
84
|
+
pool: this.props.pool || defaultPool(),
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
image: imageData,
|
|
88
|
+
height,
|
|
89
|
+
width,
|
|
90
|
+
pixelToInputCRS,
|
|
91
|
+
inputCRSToPixel,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
renderSubLayers: (props) => {
|
|
95
|
+
const { tile, data } = props;
|
|
96
|
+
const layers = [];
|
|
97
|
+
if (data) {
|
|
98
|
+
const { image, height, width, pixelToInputCRS, inputCRSToPixel, } = data;
|
|
99
|
+
const rasterLayer = new RasterLayer({
|
|
100
|
+
id: `${props.id}-raster`,
|
|
101
|
+
width,
|
|
102
|
+
height,
|
|
103
|
+
texture: image,
|
|
104
|
+
maxError,
|
|
105
|
+
reprojectionFns: {
|
|
106
|
+
pixelToInputCRS,
|
|
107
|
+
inputCRSToPixel,
|
|
108
|
+
forwardReproject,
|
|
109
|
+
inverseReproject,
|
|
110
|
+
},
|
|
111
|
+
debug,
|
|
112
|
+
debugOpacity,
|
|
113
|
+
});
|
|
114
|
+
layers.push(rasterLayer);
|
|
115
|
+
}
|
|
116
|
+
if (debug) {
|
|
117
|
+
// Get projected bounds from tile data
|
|
118
|
+
// getTileMetadata returns data that includes projectedBounds
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const projectedBounds = tile?.projectedBounds;
|
|
121
|
+
if (!projectedBounds || !metadata) {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
// Project bounds from image CRS to WGS84
|
|
125
|
+
const { topLeft, topRight, bottomLeft, bottomRight } = projectedBounds;
|
|
126
|
+
const topLeftWgs84 = metadata.projectToWgs84(topLeft);
|
|
127
|
+
const topRightWgs84 = metadata.projectToWgs84(topRight);
|
|
128
|
+
const bottomRightWgs84 = metadata.projectToWgs84(bottomRight);
|
|
129
|
+
const bottomLeftWgs84 = metadata.projectToWgs84(bottomLeft);
|
|
130
|
+
// Create a closed path around the tile bounds
|
|
131
|
+
const path = [
|
|
132
|
+
topLeftWgs84,
|
|
133
|
+
topRightWgs84,
|
|
134
|
+
bottomRightWgs84,
|
|
135
|
+
bottomLeftWgs84,
|
|
136
|
+
topLeftWgs84, // Close the path
|
|
137
|
+
];
|
|
138
|
+
layers.push(new PathLayer({
|
|
139
|
+
id: `${tile.id}-bounds`,
|
|
140
|
+
data: [{ path }],
|
|
141
|
+
getPath: (d) => d.path,
|
|
142
|
+
getColor: [255, 0, 0, 255], // Red
|
|
143
|
+
getWidth: 2,
|
|
144
|
+
widthUnits: "pixels",
|
|
145
|
+
pickable: false,
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
return layers;
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
renderLayers() {
|
|
153
|
+
const { forwardReproject, inverseReproject, metadata, images } = this.state;
|
|
154
|
+
if (!forwardReproject || !inverseReproject || !metadata || !images) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
// Split into a separate method to make TS happy, because when metadata is
|
|
158
|
+
// nullable in any part of function scope, the tileset factory wrapper gives
|
|
159
|
+
// a type error
|
|
160
|
+
return this.renderTileLayer(metadata, forwardReproject, inverseReproject, images);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Compute the affine geotransform for this tile.
|
|
165
|
+
*
|
|
166
|
+
* We need to offset the geotransform for the matrix level by the tile's pixel
|
|
167
|
+
* origin.
|
|
168
|
+
*/
|
|
169
|
+
function computeTileGeotransform(x, y, tileMatrix) {
|
|
170
|
+
const { tileWidth, tileHeight } = tileMatrix;
|
|
171
|
+
const xPixelOrigin = x * tileWidth;
|
|
172
|
+
const yPixelOrigin = y * tileHeight;
|
|
173
|
+
const [a, b, c, d, e, f] = tileMatrix.geotransform;
|
|
174
|
+
const xCoordOffset = a * xPixelOrigin + b * yPixelOrigin + c;
|
|
175
|
+
const yCoordOffset = d * xPixelOrigin + e * yPixelOrigin + f;
|
|
176
|
+
return [a, b, xCoordOffset, d, e, yCoordOffset];
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=cog-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cog-layer.js","sourceRoot":"","sources":["../src/cog-layer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAO/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMzD,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAiChC,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE,iBAAiB;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,cAA6B;IACzD,MAAM,CAAU,SAAS,GAAG,UAAU,CAAC;IACvC,MAAM,CAAU,YAAY,GAAG,YAAY,CAAC;IASnC,eAAe;QACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IAEQ,WAAW,CAAC,MAA8B;QACjD,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1B,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAEhD,MAAM,WAAW,GACf,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,Q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B,IAAI,CAAC,gBAAgB,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,0EAA0E;QAC1E,4EAA4E;QAC5E,eAAe;QACf,OAAO,IAAI,CAAC,eAAe,CACzB,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,CACP,CAAC;IACJ,CAAC;;AAGH;;;;;GAKG;AACH,SAAS,uBAAuB,CAC9B,CAAS,EACT,CAAS,EACT,UAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;IAE7C,MAAM,YAAY,GAAG,CAAC,GAAG,SAAS,CAAC;IACnC,MAAM,YAAY,GAAG,CAAC,GAAG,UAAU,CAAC;IAEpC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC;IAEnD,MAAM,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC;IAE7D,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TileMatrixSet } from "@developmentseed/deck.gl-raster";
|
|
2
|
+
import type { GeoTIFF } from "geotiff";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Ported from Vincent's work here:
|
|
6
|
+
* https://github.com/developmentseed/morecantile/pull/187/changes#diff-402eedddfa30af554d03750c8a82a09962b44b044976c321b774b484b98e8f48R665
|
|
7
|
+
*
|
|
8
|
+
* @return {TileMatrixSet}[return description]
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseCOGTileMatrixSet(tiff: GeoTIFF): Promise<TileMatrixSet>;
|
|
11
|
+
//# sourceMappingURL=cog-tile-matrix-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cog-tile-matrix-set.d.ts","sourceRoot":"","sources":["../src/cog-tile-matrix-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAarD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,aAAa,CAAC,CA0FxB"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { extractGeotransform, getGeoTIFFProjection, } from "./geotiff-reprojection";
|
|
2
|
+
import proj4 from "proj4";
|
|
3
|
+
import Ellipsoid from "./ellipsoids.js";
|
|
4
|
+
// 0.28 mm per pixel
|
|
5
|
+
// https://docs.ogc.org/is/17-083r4/17-083r4.html#toc15
|
|
6
|
+
const SCREEN_PIXEL_SIZE = 0.00028;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Ported from Vincent's work here:
|
|
10
|
+
* https://github.com/developmentseed/morecantile/pull/187/changes#diff-402eedddfa30af554d03750c8a82a09962b44b044976c321b774b484b98e8f48R665
|
|
11
|
+
*
|
|
12
|
+
* @return {TileMatrixSet}[return description]
|
|
13
|
+
*/
|
|
14
|
+
export async function parseCOGTileMatrixSet(tiff) {
|
|
15
|
+
const fullResImage = await tiff.getImage();
|
|
16
|
+
if (!fullResImage.isTiled) {
|
|
17
|
+
throw new Error("COG TileMatrixSet requires a tiled GeoTIFF");
|
|
18
|
+
}
|
|
19
|
+
const imageCount = await tiff.getImageCount();
|
|
20
|
+
const bbox = fullResImage.getBoundingBox();
|
|
21
|
+
const fullImageWidth = fullResImage.getWidth();
|
|
22
|
+
const fullImageHeight = fullResImage.getHeight();
|
|
23
|
+
const crs = await getGeoTIFFProjection(fullResImage);
|
|
24
|
+
if (crs === null) {
|
|
25
|
+
throw new Error("Could not determine coordinate reference system from GeoTIFF geo keys");
|
|
26
|
+
}
|
|
27
|
+
const parsedCrs = parseCrs(crs);
|
|
28
|
+
const projectToWgs84 = proj4(crs, "EPSG:4326").forward;
|
|
29
|
+
const projectTo3857 = proj4(crs, "EPSG:3857").forward;
|
|
30
|
+
const boundingBox = {
|
|
31
|
+
lowerLeft: [bbox[0], bbox[1]],
|
|
32
|
+
upperRight: [bbox[2], bbox[3]],
|
|
33
|
+
};
|
|
34
|
+
const transform = extractGeotransform(fullResImage);
|
|
35
|
+
if (transform[1] !== 0 || transform[3] !== 0) {
|
|
36
|
+
// TileMatrixSet assumes orthogonal axes
|
|
37
|
+
throw new Error("COG TileMatrixSet with rotation/skewed geotransform is not supported");
|
|
38
|
+
}
|
|
39
|
+
const cellSize = Math.abs(transform[0]);
|
|
40
|
+
const tileWidth = fullResImage.getTileWidth();
|
|
41
|
+
const tileHeight = fullResImage.getTileHeight();
|
|
42
|
+
const tileMatrices = [
|
|
43
|
+
{
|
|
44
|
+
// Set as highest resolution / finest level
|
|
45
|
+
id: String(imageCount - 1),
|
|
46
|
+
scaleDenominator: (cellSize * metersPerUnit(parsedCrs)) / SCREEN_PIXEL_SIZE,
|
|
47
|
+
cellSize,
|
|
48
|
+
pointOfOrigin: [transform[2], transform[5]],
|
|
49
|
+
tileWidth: fullResImage.getTileWidth(),
|
|
50
|
+
tileHeight: fullResImage.getTileHeight(),
|
|
51
|
+
matrixWidth: Math.ceil(fullImageWidth / tileWidth),
|
|
52
|
+
matrixHeight: Math.ceil(fullImageHeight / tileHeight),
|
|
53
|
+
geotransform: transform,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
// Starting from 1 to skip full res image
|
|
57
|
+
for (let imageIdx = 1; imageIdx < imageCount; imageIdx++) {
|
|
58
|
+
const image = await tiff.getImage(imageIdx);
|
|
59
|
+
if (!image.isTiled) {
|
|
60
|
+
throw new Error("COG TileMatrixSet requires a tiled GeoTIFF");
|
|
61
|
+
}
|
|
62
|
+
const tileMatrix = createOverviewTileMatrix({
|
|
63
|
+
id: String(imageCount - 1 - imageIdx),
|
|
64
|
+
image,
|
|
65
|
+
fullWidth: fullImageWidth,
|
|
66
|
+
fullHeight: fullImageHeight,
|
|
67
|
+
baseTransform: transform,
|
|
68
|
+
parsedCrs,
|
|
69
|
+
});
|
|
70
|
+
tileMatrices.push(tileMatrix);
|
|
71
|
+
}
|
|
72
|
+
// Reverse to have coarsest level first
|
|
73
|
+
tileMatrices.reverse();
|
|
74
|
+
return {
|
|
75
|
+
crs,
|
|
76
|
+
boundingBox,
|
|
77
|
+
wgsBounds: computeWgs84BoundingBox(boundingBox, projectToWgs84),
|
|
78
|
+
tileMatrices,
|
|
79
|
+
projectToWgs84,
|
|
80
|
+
projectTo3857,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Coefficient to convert the coordinate reference system (CRS)
|
|
85
|
+
* units into meters (metersPerUnit).
|
|
86
|
+
*
|
|
87
|
+
* From note g in http://docs.opengeospatial.org/is/17-083r2/17-083r2.html#table_2:
|
|
88
|
+
*
|
|
89
|
+
* > If the CRS uses meters as units of measure for the horizontal dimensions,
|
|
90
|
+
* > then metersPerUnit=1; if it has degrees, then metersPerUnit=2pa/360
|
|
91
|
+
* > (a is the Earth maximum radius of the ellipsoid).
|
|
92
|
+
*/
|
|
93
|
+
// https://github.com/developmentseed/morecantile/blob/7c95a11c491303700d6e33e9c1607f2719584dec/morecantile/utils.py#L67-L90
|
|
94
|
+
function metersPerUnit(parsedCrs) {
|
|
95
|
+
switch (parsedCrs.units) {
|
|
96
|
+
case "metre":
|
|
97
|
+
case "meter":
|
|
98
|
+
case "meters":
|
|
99
|
+
return 1;
|
|
100
|
+
case "foot":
|
|
101
|
+
return 0.3048;
|
|
102
|
+
case "US survey foot":
|
|
103
|
+
return 1200 / 3937;
|
|
104
|
+
}
|
|
105
|
+
if (parsedCrs.units === "degree") {
|
|
106
|
+
// 2 * π * ellipsoid semi-major-axis / 360
|
|
107
|
+
const { a } = Ellipsoid[parsedCrs.ellps];
|
|
108
|
+
return (2 * Math.PI * a) / 360;
|
|
109
|
+
}
|
|
110
|
+
throw new Error(`Unsupported CRS units: ${parsedCrs.units}`);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create tile matrix for COG overview
|
|
114
|
+
*/
|
|
115
|
+
function createOverviewTileMatrix({ id, image, fullWidth, baseTransform, parsedCrs, }) {
|
|
116
|
+
const width = image.getWidth();
|
|
117
|
+
const height = image.getHeight();
|
|
118
|
+
// For now, just use scaleX
|
|
119
|
+
// https://github.com/developmentseed/morecantile/pull/187/changes#r2621314673
|
|
120
|
+
const scaleX = fullWidth / width;
|
|
121
|
+
// const scaleY = fullHeight / height;
|
|
122
|
+
// if (Math.abs(scaleX - scaleY) > 1e-3) {
|
|
123
|
+
// throw new Error("Non-uniform overview scaling detected (X/Y differ)");
|
|
124
|
+
// }
|
|
125
|
+
const scale = scaleX;
|
|
126
|
+
const geotransform = [
|
|
127
|
+
baseTransform[0] * scale,
|
|
128
|
+
baseTransform[1] * scale,
|
|
129
|
+
baseTransform[2], // x origin stays the same
|
|
130
|
+
baseTransform[3] * scale,
|
|
131
|
+
baseTransform[4] * scale,
|
|
132
|
+
baseTransform[5], // y origin stays the same
|
|
133
|
+
];
|
|
134
|
+
const cellSize = Math.abs(geotransform[0]);
|
|
135
|
+
const tileWidth = image.getTileWidth();
|
|
136
|
+
const tileHeight = image.getTileHeight();
|
|
137
|
+
return {
|
|
138
|
+
id,
|
|
139
|
+
scaleDenominator: (cellSize * metersPerUnit(parsedCrs)) / SCREEN_PIXEL_SIZE,
|
|
140
|
+
cellSize,
|
|
141
|
+
pointOfOrigin: [geotransform[2], geotransform[5]],
|
|
142
|
+
tileWidth,
|
|
143
|
+
tileHeight,
|
|
144
|
+
matrixWidth: Math.ceil(width / tileWidth),
|
|
145
|
+
matrixHeight: Math.ceil(height / tileHeight),
|
|
146
|
+
geotransform,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function parseCrs(crs) {
|
|
150
|
+
// If you pass proj4.defs a projjson, it doesn't parse it; it just returns the
|
|
151
|
+
// input.
|
|
152
|
+
//
|
|
153
|
+
// Instead, you need to assign it to an alias and then retrieve it.
|
|
154
|
+
const key = "__deck.gl-geotiff-internal__";
|
|
155
|
+
proj4.defs(key, crs);
|
|
156
|
+
return proj4.defs(key);
|
|
157
|
+
}
|
|
158
|
+
function computeWgs84BoundingBox(boundingBox, projectToWgs84) {
|
|
159
|
+
const lowerLeftWgs84 = projectToWgs84(boundingBox.lowerLeft);
|
|
160
|
+
const lowerRightWgs84 = projectToWgs84([
|
|
161
|
+
boundingBox.upperRight[0],
|
|
162
|
+
boundingBox.lowerLeft[1],
|
|
163
|
+
]);
|
|
164
|
+
const upperRightWgs84 = projectToWgs84(boundingBox.upperRight);
|
|
165
|
+
const upperLeftWgs84 = projectToWgs84([
|
|
166
|
+
boundingBox.lowerLeft[0],
|
|
167
|
+
boundingBox.upperRight[1],
|
|
168
|
+
]);
|
|
169
|
+
// Compute min/max lat/lon
|
|
170
|
+
const minLon = Math.min(lowerLeftWgs84[0], lowerRightWgs84[0], upperRightWgs84[0], upperLeftWgs84[0]);
|
|
171
|
+
const maxLon = Math.max(lowerLeftWgs84[0], lowerRightWgs84[0], upperRightWgs84[0], upperLeftWgs84[0]);
|
|
172
|
+
const minLat = Math.min(lowerLeftWgs84[1], lowerRightWgs84[1], upperRightWgs84[1], upperLeftWgs84[1]);
|
|
173
|
+
const maxLat = Math.max(lowerLeftWgs84[1], lowerRightWgs84[1], upperRightWgs84[1], upperLeftWgs84[1]);
|
|
174
|
+
return {
|
|
175
|
+
lowerLeft: [minLon, minLat],
|
|
176
|
+
upperRight: [maxLon, maxLat],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMapping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AC,GAAG,CACrB,cAAc,CAAC,CAAC,CAAC,EACjB,eAAe,CAAC,CAAC,CAAC,EAClB,eAAe,CAAC,CAAC,CAAC,EAClB,cAAc,CAAC,CAAC,CAAC,CAClB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACrB,cAAc,CAAC,CAAC,CAAC,EACjB,eAAe,CAAC,CAAC,CAAC,EAClB,eAAe,CAAC,CAAC,CAAC,EAClB,cAAc,CAAC,CAAC,CAAC,CAClB,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored and edited from proj4.js.
|
|
3
|
+
*
|
|
4
|
+
* In the implementation of metersPerUnit while generated a COG TileMatrixSet,
|
|
5
|
+
* we need to know the size of the semi major axis in the case the CRS is in
|
|
6
|
+
* degrees.
|
|
7
|
+
*
|
|
8
|
+
* https://github.com/proj4js/proj4js/blob/e90e5fa6872a1ffc40edb161cbeb4bd5e3bd9db5/lib/constants/Ellipsoid.js
|
|
9
|
+
*/
|
|
10
|
+
declare const ellipsoids: {
|
|
11
|
+
MERIT: {
|
|
12
|
+
a: number;
|
|
13
|
+
};
|
|
14
|
+
SGS85: {
|
|
15
|
+
a: number;
|
|
16
|
+
};
|
|
17
|
+
GRS80: {
|
|
18
|
+
a: number;
|
|
19
|
+
};
|
|
20
|
+
IAU76: {
|
|
21
|
+
a: number;
|
|
22
|
+
};
|
|
23
|
+
airy: {
|
|
24
|
+
a: number;
|
|
25
|
+
b: number;
|
|
26
|
+
};
|
|
27
|
+
APL4: {
|
|
28
|
+
a: number;
|
|
29
|
+
};
|
|
30
|
+
NWL9D: {
|
|
31
|
+
a: number;
|
|
32
|
+
};
|
|
33
|
+
mod_airy: {
|
|
34
|
+
a: number;
|
|
35
|
+
b: number;
|
|
36
|
+
};
|
|
37
|
+
andrae: {
|
|
38
|
+
a: number;
|
|
39
|
+
};
|
|
40
|
+
aust_SA: {
|
|
41
|
+
a: number;
|
|
42
|
+
};
|
|
43
|
+
GRS67: {
|
|
44
|
+
a: number;
|
|
45
|
+
};
|
|
46
|
+
bessel: {
|
|
47
|
+
a: number;
|
|
48
|
+
};
|
|
49
|
+
bess_nam: {
|
|
50
|
+
a: number;
|
|
51
|
+
};
|
|
52
|
+
clrk66: {
|
|
53
|
+
a: number;
|
|
54
|
+
b: number;
|
|
55
|
+
};
|
|
56
|
+
clrk80: {
|
|
57
|
+
a: number;
|
|
58
|
+
};
|
|
59
|
+
clrk80ign: {
|
|
60
|
+
a: number;
|
|
61
|
+
b: number;
|
|
62
|
+
};
|
|
63
|
+
clrk58: {
|
|
64
|
+
a: number;
|
|
65
|
+
};
|
|
66
|
+
CPM: {
|
|
67
|
+
a: number;
|
|
68
|
+
};
|
|
69
|
+
delmbr: {
|
|
70
|
+
a: number;
|
|
71
|
+
};
|
|
72
|
+
engelis: {
|
|
73
|
+
a: number;
|
|
74
|
+
};
|
|
75
|
+
evrst30: {
|
|
76
|
+
a: number;
|
|
77
|
+
};
|
|
78
|
+
evrst48: {
|
|
79
|
+
a: number;
|
|
80
|
+
};
|
|
81
|
+
evrst56: {
|
|
82
|
+
a: number;
|
|
83
|
+
};
|
|
84
|
+
evrst69: {
|
|
85
|
+
a: number;
|
|
86
|
+
};
|
|
87
|
+
evrstSS: {
|
|
88
|
+
a: number;
|
|
89
|
+
};
|
|
90
|
+
fschr60: {
|
|
91
|
+
a: number;
|
|
92
|
+
};
|
|
93
|
+
fschr60m: {
|
|
94
|
+
a: number;
|
|
95
|
+
};
|
|
96
|
+
fschr68: {
|
|
97
|
+
a: number;
|
|
98
|
+
};
|
|
99
|
+
helmert: {
|
|
100
|
+
a: number;
|
|
101
|
+
};
|
|
102
|
+
hough: {
|
|
103
|
+
a: number;
|
|
104
|
+
};
|
|
105
|
+
intl: {
|
|
106
|
+
a: number;
|
|
107
|
+
};
|
|
108
|
+
kaula: {
|
|
109
|
+
a: number;
|
|
110
|
+
};
|
|
111
|
+
lerch: {
|
|
112
|
+
a: number;
|
|
113
|
+
};
|
|
114
|
+
mprts: {
|
|
115
|
+
a: number;
|
|
116
|
+
};
|
|
117
|
+
new_intl: {
|
|
118
|
+
a: number;
|
|
119
|
+
b: number;
|
|
120
|
+
};
|
|
121
|
+
plessis: {
|
|
122
|
+
a: number;
|
|
123
|
+
};
|
|
124
|
+
krass: {
|
|
125
|
+
a: number;
|
|
126
|
+
};
|
|
127
|
+
SEasia: {
|
|
128
|
+
a: number;
|
|
129
|
+
b: number;
|
|
130
|
+
};
|
|
131
|
+
walbeck: {
|
|
132
|
+
a: number;
|
|
133
|
+
b: number;
|
|
134
|
+
};
|
|
135
|
+
WGS60: {
|
|
136
|
+
a: number;
|
|
137
|
+
};
|
|
138
|
+
WGS66: {
|
|
139
|
+
a: number;
|
|
140
|
+
};
|
|
141
|
+
WGS7: {
|
|
142
|
+
a: number;
|
|
143
|
+
};
|
|
144
|
+
WGS84: {
|
|
145
|
+
a: number;
|
|
146
|
+
};
|
|
147
|
+
sphere: {
|
|
148
|
+
a: number;
|
|
149
|
+
b: number;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export default ellipsoids;
|
|
153
|
+
//# sourceMappingURL=ellipsoids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ellipsoids.d.ts","sourceRoot":"","sources":["../src/ellipsoids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6If,CAAC;AAEF,eAAe,UAAU,CAAC"}
|