@developmentseed/deck.gl-geotiff 0.2.0 → 0.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cog-layer.d.ts +34 -35
- package/dist/cog-layer.d.ts.map +1 -1
- package/dist/cog-layer.js +71 -76
- package/dist/cog-layer.js.map +1 -1
- package/dist/cog-tile-matrix-set.d.ts +2 -31
- package/dist/cog-tile-matrix-set.d.ts.map +1 -1
- package/dist/cog-tile-matrix-set.js +2 -159
- package/dist/cog-tile-matrix-set.js.map +1 -1
- package/dist/geotiff/geotiff.d.ts +5 -43
- package/dist/geotiff/geotiff.d.ts.map +1 -1
- package/dist/geotiff/geotiff.js +28 -101
- package/dist/geotiff/geotiff.js.map +1 -1
- package/dist/geotiff/high-level/affine.d.ts +16 -0
- package/dist/geotiff/high-level/affine.d.ts.map +1 -0
- package/dist/geotiff/high-level/affine.js +2 -0
- package/dist/geotiff/high-level/affine.js.map +1 -0
- package/dist/geotiff/high-level/array.d.ts +37 -0
- package/dist/geotiff/high-level/array.d.ts.map +1 -0
- package/dist/geotiff/high-level/array.js +2 -0
- package/dist/geotiff/high-level/array.js.map +1 -0
- package/dist/geotiff/high-level/geotiff.d.ts +63 -0
- package/dist/geotiff/high-level/geotiff.d.ts.map +1 -0
- package/dist/geotiff/high-level/geotiff.js +135 -0
- package/dist/geotiff/high-level/geotiff.js.map +1 -0
- package/dist/geotiff/high-level/index.d.ts +8 -0
- package/dist/geotiff/high-level/index.d.ts.map +1 -0
- package/dist/geotiff/high-level/index.js +5 -0
- package/dist/geotiff/high-level/index.js.map +1 -0
- package/dist/geotiff/high-level/options.d.ts +11 -0
- package/dist/geotiff/high-level/options.d.ts.map +1 -0
- package/dist/geotiff/high-level/options.js +2 -0
- package/dist/geotiff/high-level/options.js.map +1 -0
- package/dist/geotiff/high-level/overview.d.ts +46 -0
- package/dist/geotiff/high-level/overview.d.ts.map +1 -0
- package/dist/geotiff/high-level/overview.js +124 -0
- package/dist/geotiff/high-level/overview.js.map +1 -0
- package/dist/geotiff/high-level/tile.d.ts +11 -0
- package/dist/geotiff/high-level/tile.d.ts.map +1 -0
- package/dist/geotiff/high-level/tile.js +2 -0
- package/dist/geotiff/high-level/tile.js.map +1 -0
- package/dist/geotiff/high-level/transform.d.ts +23 -0
- package/dist/geotiff/high-level/transform.d.ts.map +1 -0
- package/dist/geotiff/high-level/transform.js +55 -0
- package/dist/geotiff/high-level/transform.js.map +1 -0
- package/dist/geotiff/high-level/window.d.ts +23 -0
- package/dist/geotiff/high-level/window.d.ts.map +1 -0
- package/dist/geotiff/high-level/window.js +31 -0
- package/dist/geotiff/high-level/window.js.map +1 -0
- package/dist/geotiff/render-pipeline.d.ts +2 -2
- package/dist/geotiff/render-pipeline.d.ts.map +1 -1
- package/dist/geotiff/render-pipeline.js +47 -44
- package/dist/geotiff/render-pipeline.js.map +1 -1
- package/dist/geotiff/texture.d.ts +5 -4
- package/dist/geotiff/texture.d.ts.map +1 -1
- package/dist/geotiff/texture.js +7 -7
- package/dist/geotiff/texture.js.map +1 -1
- package/dist/geotiff/types.d.ts +0 -29
- package/dist/geotiff/types.d.ts.map +1 -1
- package/dist/geotiff/types.js +1 -12
- package/dist/geotiff/types.js.map +1 -1
- package/dist/geotiff-layer.d.ts +17 -21
- package/dist/geotiff-layer.d.ts.map +1 -1
- package/dist/geotiff-layer.js +25 -21
- package/dist/geotiff-layer.js.map +1 -1
- package/dist/geotiff-reprojection.d.ts +4 -18
- package/dist/geotiff-reprojection.d.ts.map +1 -1
- package/dist/geotiff-reprojection.js +9 -126
- package/dist/geotiff-reprojection.js.map +1 -1
- package/dist/geotiff-types.d.ts +13 -0
- package/dist/geotiff-types.d.ts.map +1 -0
- package/dist/geotiff-types.js +2 -0
- package/dist/geotiff-types.js.map +1 -0
- package/dist/geotiff.d.ts +50 -0
- package/dist/geotiff.d.ts.map +1 -0
- package/dist/geotiff.js +135 -0
- package/dist/geotiff.js.map +1 -0
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/mosaic-layer/mosaic-tile-traversal.d.ts +1 -0
- package/dist/mosaic-layer/mosaic-tile-traversal.d.ts.map +1 -0
- package/dist/mosaic-layer/mosaic-tile-traversal.js +2 -0
- package/dist/mosaic-layer/mosaic-tile-traversal.js.map +1 -0
- package/dist/mosaic-layer.d.ts +1 -0
- package/dist/mosaic-layer.d.ts.map +1 -0
- package/dist/mosaic-layer.js +2 -0
- package/dist/mosaic-layer.js.map +1 -0
- package/dist/proj.d.ts +3 -23
- package/dist/proj.d.ts.map +1 -1
- package/dist/proj.js +20 -38
- package/dist/proj.js.map +1 -1
- package/dist/texture.d.ts +10 -0
- package/dist/texture.d.ts.map +1 -0
- package/dist/texture.js +135 -0
- package/dist/texture.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +15 -11
|
@@ -1,89 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { applyAffine, invertGeoTransform, } from "@developmentseed/raster-reproject/affine";
|
|
1
|
+
import * as affine from "@developmentseed/affine";
|
|
3
2
|
import proj4 from "proj4";
|
|
4
|
-
export const OGC_84 = {
|
|
5
|
-
$schema: "https://proj.org/schemas/v0.7/projjson.schema.json",
|
|
6
|
-
type: "GeographicCRS",
|
|
7
|
-
name: "WGS 84 (CRS84)",
|
|
8
|
-
datum_ensemble: {
|
|
9
|
-
name: "World Geodetic System 1984 ensemble",
|
|
10
|
-
members: [
|
|
11
|
-
{
|
|
12
|
-
name: "World Geodetic System 1984 (Transit)",
|
|
13
|
-
id: { authority: "EPSG", code: 1166 },
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "World Geodetic System 1984 (G730)",
|
|
17
|
-
id: { authority: "EPSG", code: 1152 },
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "World Geodetic System 1984 (G873)",
|
|
21
|
-
id: { authority: "EPSG", code: 1153 },
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "World Geodetic System 1984 (G1150)",
|
|
25
|
-
id: { authority: "EPSG", code: 1154 },
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "World Geodetic System 1984 (G1674)",
|
|
29
|
-
id: { authority: "EPSG", code: 1155 },
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "World Geodetic System 1984 (G1762)",
|
|
33
|
-
id: { authority: "EPSG", code: 1156 },
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "World Geodetic System 1984 (G2139)",
|
|
37
|
-
id: { authority: "EPSG", code: 1309 },
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
ellipsoid: {
|
|
41
|
-
name: "WGS 84",
|
|
42
|
-
semi_major_axis: 6378137,
|
|
43
|
-
inverse_flattening: 298.257223563,
|
|
44
|
-
},
|
|
45
|
-
accuracy: "2.0",
|
|
46
|
-
id: { authority: "EPSG", code: 6326 },
|
|
47
|
-
},
|
|
48
|
-
coordinate_system: {
|
|
49
|
-
subtype: "ellipsoidal",
|
|
50
|
-
axis: [
|
|
51
|
-
{
|
|
52
|
-
name: "Geodetic longitude",
|
|
53
|
-
abbreviation: "Lon",
|
|
54
|
-
direction: "east",
|
|
55
|
-
unit: "degree",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "Geodetic latitude",
|
|
59
|
-
abbreviation: "Lat",
|
|
60
|
-
direction: "north",
|
|
61
|
-
unit: "degree",
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
scope: "Not known.",
|
|
66
|
-
area: "World.",
|
|
67
|
-
bbox: {
|
|
68
|
-
south_latitude: -90,
|
|
69
|
-
west_longitude: -180,
|
|
70
|
-
north_latitude: 90,
|
|
71
|
-
east_longitude: 180,
|
|
72
|
-
},
|
|
73
|
-
// @ts-expect-error - proj4 types are incomplete
|
|
74
|
-
id: { authority: "OGC", code: "CRS84" },
|
|
75
|
-
};
|
|
76
3
|
// Derived from existing work here:
|
|
77
4
|
// https://github.com/developmentseed/lonboard/blob/35a1f3d691604ad9e083bf10a4bfde4158171486/src/cog-tileset/claude-tileset-2d-improved.ts#L141
|
|
78
5
|
//
|
|
79
6
|
// TODO: return a RasterReprojector instance, given the IFD and tile of interest?
|
|
80
|
-
export async function extractGeotiffReprojectors(
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
// Only the top-level IFD has geo keys, so we'll derive overviews from this
|
|
84
|
-
const baseGeotransform = extractGeotransform(image);
|
|
7
|
+
export async function extractGeotiffReprojectors(geotiff, sourceProjection, outputCrs = "EPSG:4326") {
|
|
8
|
+
// @ts-expect-error - proj4 type definitions are incomplete and don't include
|
|
9
|
+
// support for wkt-parser output
|
|
85
10
|
const converter = proj4(sourceProjection, outputCrs);
|
|
86
|
-
const { forwardTransform, inverseTransform } =
|
|
11
|
+
const { forwardTransform, inverseTransform } = fromAffine(geotiff.transform);
|
|
87
12
|
return {
|
|
88
13
|
forwardTransform,
|
|
89
14
|
inverseTransform,
|
|
@@ -91,53 +16,11 @@ export async function extractGeotiffReprojectors(tiff, sourceProjection, outputC
|
|
|
91
16
|
inverseReproject: (x, y) => converter.inverse([x, y], false),
|
|
92
17
|
};
|
|
93
18
|
}
|
|
94
|
-
export function
|
|
95
|
-
const inverseGeotransform =
|
|
19
|
+
export function fromAffine(geotransform) {
|
|
20
|
+
const inverseGeotransform = affine.invert(geotransform);
|
|
96
21
|
return {
|
|
97
|
-
forwardTransform: (x, y) =>
|
|
98
|
-
inverseTransform: (x, y) =>
|
|
22
|
+
forwardTransform: (x, y) => affine.apply(geotransform, x, y),
|
|
23
|
+
inverseTransform: (x, y) => affine.apply(inverseGeotransform, x, y),
|
|
99
24
|
};
|
|
100
25
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Extract affine geotransform from a GeoTIFF image.
|
|
103
|
-
*
|
|
104
|
-
* The first `image` must be passed in, as only the top-level IFD contains geo
|
|
105
|
-
* keys.
|
|
106
|
-
*
|
|
107
|
-
* Returns a 6-element array in Python `affine` package ordering:
|
|
108
|
-
* [a, b, c, d, e, f] where:
|
|
109
|
-
* - x_geo = a * col + b * row + c
|
|
110
|
-
* - y_geo = d * col + e * row + f
|
|
111
|
-
*
|
|
112
|
-
* This is NOT GDAL ordering, which is [c, a, b, f, d, e].
|
|
113
|
-
*/
|
|
114
|
-
export function extractGeotransform(image) {
|
|
115
|
-
const origin = image.getOrigin();
|
|
116
|
-
const resolution = image.getResolution();
|
|
117
|
-
// origin: [x, y, z]
|
|
118
|
-
// resolution: [x_res, y_res, z_res]
|
|
119
|
-
// Check for rotation/skew in the file directory
|
|
120
|
-
const fileDirectory = image.getFileDirectory();
|
|
121
|
-
const modelTransformation = fileDirectory.ModelTransformation;
|
|
122
|
-
let b = 0; // row rotation
|
|
123
|
-
let d = 0; // column rotation
|
|
124
|
-
if (modelTransformation && modelTransformation.length >= 16) {
|
|
125
|
-
// ModelTransformation is a 4x4 matrix in row-major order
|
|
126
|
-
// [0 1 2 3 ] [a b 0 c]
|
|
127
|
-
// [4 5 6 7 ] = [d e 0 f]
|
|
128
|
-
// [8 9 10 11] [0 0 1 0]
|
|
129
|
-
// [12 13 14 15] [0 0 0 1]
|
|
130
|
-
b = modelTransformation[1];
|
|
131
|
-
d = modelTransformation[4];
|
|
132
|
-
}
|
|
133
|
-
// Return in affine package ordering: [a, b, c, d, e, f]
|
|
134
|
-
return [
|
|
135
|
-
resolution[0], // a: pixel width
|
|
136
|
-
b, // b: row rotation
|
|
137
|
-
origin[0], // c: x origin
|
|
138
|
-
d, // d: column rotation
|
|
139
|
-
resolution[1], // e: pixel height (often negative)
|
|
140
|
-
origin[1],
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
26
|
//# sourceMappingURL=geotiff-reprojection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAGlD,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,mCAAmC;AACnC,+IAA+I;AAC/I,EAAE;AACF,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAAgB,EAChB,gBAAoE,EACpE,YAAsD,WAAW;IAEjE,6EAA6E;IAC7E,gCAAgC;IAChC,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE7E,OAAO;QACL,gBAAgB;QAChB,gBAAgB;QAChB,gBAAgB,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACzC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;QAClC,gBAAgB,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACzC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,YAA8D;IAK9D,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACxD,OAAO;QACL,gBAAgB,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACzC,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;QAClC,gBAAgB,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACzC,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,CAAC,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { globals } from "geotiff";
|
|
2
|
+
/** Improved typing for IFD. */
|
|
3
|
+
export type ImageFileDirectory = {
|
|
4
|
+
ImageWidth: number;
|
|
5
|
+
ImageLength: number;
|
|
6
|
+
BitsPerSample: Uint16Array;
|
|
7
|
+
Compression: number;
|
|
8
|
+
PhotometricInterpretation: typeof globals.photometricInterpretations;
|
|
9
|
+
SamplesPerPixel: number;
|
|
10
|
+
SampleFormat: Uint16Array;
|
|
11
|
+
PlanarConfiguration: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=geotiff-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geotiff-types.d.ts","sourceRoot":"","sources":["../src/geotiff-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,WAAW,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,OAAO,OAAO,CAAC,0BAA0B,CAAC;IACrE,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,WAAW,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geotiff-types.js","sourceRoot":"","sources":["../src/geotiff-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { GeoTIFF, GeoTIFFImage } from "geotiff";
|
|
2
|
+
import { BaseClient, Pool } from "geotiff";
|
|
3
|
+
import type { Converter } from "proj4";
|
|
4
|
+
/**
|
|
5
|
+
* Options that may be passed when reading image data from geotiff.js
|
|
6
|
+
*/
|
|
7
|
+
type ReadRasterOptions = {
|
|
8
|
+
/** the subset to read data from in pixels. */
|
|
9
|
+
window?: [number, number, number, number];
|
|
10
|
+
/** The optional decoder pool to use. */
|
|
11
|
+
pool?: Pool;
|
|
12
|
+
/** An AbortSignal that may be signalled if the request is to be aborted */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Retrieve the default geotiff.js decoder Pool.
|
|
17
|
+
*
|
|
18
|
+
* If a Pool has not yet been created, it will be created on first call.
|
|
19
|
+
*
|
|
20
|
+
* The Pool will be shared between all COGLayer and GeoTIFFLayer instances.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defaultPool(): Pool;
|
|
23
|
+
/**
|
|
24
|
+
* Load an RGBA image from a GeoTIFFImage.
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadRgbImage(image: GeoTIFFImage, options?: ReadRasterOptions): Promise<{
|
|
27
|
+
texture: ImageData;
|
|
28
|
+
height: number;
|
|
29
|
+
width: number;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Parse the GeoTIFF `ColorMap` tag into an ImageData.
|
|
33
|
+
*
|
|
34
|
+
* @param {Uint16Array} cmap The colormap array from the GeoTIFF `ColorMap` tag.
|
|
35
|
+
*
|
|
36
|
+
* @return {ImageData} The parsed colormap as an ImageData object.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseColormap(cmap: Uint16Array): ImageData;
|
|
39
|
+
export declare function fetchGeoTIFF(input: GeoTIFF | string | ArrayBuffer | Blob | BaseClient): Promise<GeoTIFF>;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate the WGS84 bounding box of a GeoTIFF image
|
|
42
|
+
*/
|
|
43
|
+
export declare function getGeographicBounds(image: GeoTIFFImage, converter: Converter): {
|
|
44
|
+
west: number;
|
|
45
|
+
south: number;
|
|
46
|
+
east: number;
|
|
47
|
+
north: number;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
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AM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA4B9D"}
|
package/dist/geotiff.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Utilities for interacting with geotiff.js.
|
|
2
|
+
import { BaseClient, fromArrayBuffer, fromBlob, fromCustomClient, fromUrl, Pool, } from "geotiff";
|
|
3
|
+
/**
|
|
4
|
+
* A default geotiff.js decoder pool instance.
|
|
5
|
+
*
|
|
6
|
+
* It will be created on first call of `defaultPool`.
|
|
7
|
+
*/
|
|
8
|
+
let DEFAULT_POOL = null;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve the default geotiff.js decoder Pool.
|
|
11
|
+
*
|
|
12
|
+
* If a Pool has not yet been created, it will be created on first call.
|
|
13
|
+
*
|
|
14
|
+
* The Pool will be shared between all COGLayer and GeoTIFFLayer instances.
|
|
15
|
+
*/
|
|
16
|
+
export function defaultPool() {
|
|
17
|
+
if (DEFAULT_POOL === null) {
|
|
18
|
+
DEFAULT_POOL = new Pool();
|
|
19
|
+
}
|
|
20
|
+
return DEFAULT_POOL;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Load an RGBA image from a GeoTIFFImage.
|
|
24
|
+
*/
|
|
25
|
+
export async function loadRgbImage(image, options) {
|
|
26
|
+
const mergedOptions = {
|
|
27
|
+
...options,
|
|
28
|
+
interleave: true,
|
|
29
|
+
enableAlpha: true,
|
|
30
|
+
};
|
|
31
|
+
// Since we set interleave: true, the result is a single array with all
|
|
32
|
+
// samples, so we cast to TypedArrayWithDimensions
|
|
33
|
+
// https://github.com/geotiffjs/geotiff.js/issues/486
|
|
34
|
+
const rgbImage = (await image.readRGB(mergedOptions));
|
|
35
|
+
const imageData = addAlphaChannel(rgbImage);
|
|
36
|
+
return {
|
|
37
|
+
texture: imageData,
|
|
38
|
+
height: rgbImage.height,
|
|
39
|
+
width: rgbImage.width,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Add an alpha channel to an RGB image array.
|
|
44
|
+
*
|
|
45
|
+
* Only supports input arrays with 3 (RGB) or 4 (RGBA) channels. If the input is
|
|
46
|
+
* already RGBA, it is returned unchanged.
|
|
47
|
+
*/
|
|
48
|
+
function addAlphaChannel(rgbImage) {
|
|
49
|
+
const { height, width } = rgbImage;
|
|
50
|
+
if (rgbImage.length === height * width * 4) {
|
|
51
|
+
// Already has alpha channel
|
|
52
|
+
return new ImageData(new Uint8ClampedArray(rgbImage), width, height);
|
|
53
|
+
}
|
|
54
|
+
else if (rgbImage.length === height * width * 3) {
|
|
55
|
+
// Need to add alpha channel
|
|
56
|
+
const rgbaLength = (rgbImage.length / 3) * 4;
|
|
57
|
+
const rgbaArray = new Uint8ClampedArray(rgbaLength);
|
|
58
|
+
for (let i = 0; i < rgbImage.length / 3; ++i) {
|
|
59
|
+
rgbaArray[i * 4] = rgbImage[i * 3];
|
|
60
|
+
rgbaArray[i * 4 + 1] = rgbImage[i * 3 + 1];
|
|
61
|
+
rgbaArray[i * 4 + 2] = rgbImage[i * 3 + 2];
|
|
62
|
+
rgbaArray[i * 4 + 3] = 255;
|
|
63
|
+
}
|
|
64
|
+
return new ImageData(rgbaArray, width, height);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error(`Unexpected number of channels in raster data: ${rgbImage.length / (height * width)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse the GeoTIFF `ColorMap` tag into an ImageData.
|
|
72
|
+
*
|
|
73
|
+
* @param {Uint16Array} cmap The colormap array from the GeoTIFF `ColorMap` tag.
|
|
74
|
+
*
|
|
75
|
+
* @return {ImageData} The parsed colormap as an ImageData object.
|
|
76
|
+
*/
|
|
77
|
+
export function parseColormap(cmap) {
|
|
78
|
+
// TODO: test colormap handling on a 16-bit image with 2^16 entries?
|
|
79
|
+
const size = cmap.length / 3;
|
|
80
|
+
const rgba = new Uint8ClampedArray(size * 4);
|
|
81
|
+
const rOffset = 0;
|
|
82
|
+
const gOffset = size;
|
|
83
|
+
const bOffset = size * 2;
|
|
84
|
+
// Note: >> 8 is needed to convert from 16-bit to 8-bit color values
|
|
85
|
+
// It just divides by 256 and floors to nearest integer
|
|
86
|
+
for (let i = 0; i < size; i++) {
|
|
87
|
+
rgba[4 * i + 0] = cmap[rOffset + i] >> 8;
|
|
88
|
+
rgba[4 * i + 1] = cmap[gOffset + i] >> 8;
|
|
89
|
+
rgba[4 * i + 2] = cmap[bOffset + i] >> 8;
|
|
90
|
+
// Full opacity
|
|
91
|
+
rgba[4 * i + 3] = 255;
|
|
92
|
+
}
|
|
93
|
+
return new ImageData(rgba, size, 1);
|
|
94
|
+
}
|
|
95
|
+
export async function fetchGeoTIFF(input) {
|
|
96
|
+
if (typeof input === "string") {
|
|
97
|
+
return fromUrl(input);
|
|
98
|
+
}
|
|
99
|
+
if (input instanceof ArrayBuffer) {
|
|
100
|
+
return fromArrayBuffer(input);
|
|
101
|
+
}
|
|
102
|
+
if (input instanceof Blob) {
|
|
103
|
+
return fromBlob(input);
|
|
104
|
+
}
|
|
105
|
+
// TODO: instanceof may fail here if multiple versions of geotiff.js are
|
|
106
|
+
// present
|
|
107
|
+
if (input instanceof BaseClient) {
|
|
108
|
+
return fromCustomClient(input);
|
|
109
|
+
}
|
|
110
|
+
return input;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Calculate the WGS84 bounding box of a GeoTIFF image
|
|
114
|
+
*/
|
|
115
|
+
export function getGeographicBounds(image, converter) {
|
|
116
|
+
const projectedBbox = image.getBoundingBox();
|
|
117
|
+
// Reproject all four corners to handle rotation/skew
|
|
118
|
+
const [minX, minY, maxX, maxY] = projectedBbox;
|
|
119
|
+
const corners = [
|
|
120
|
+
converter.forward([minX, minY]), // bottom-left
|
|
121
|
+
converter.forward([maxX, minY]), // bottom-right
|
|
122
|
+
converter.forward([maxX, maxY]), // top-right
|
|
123
|
+
converter.forward([minX, maxY]), // top-left
|
|
124
|
+
];
|
|
125
|
+
// Find the bounding box that encompasses all reprojected corners
|
|
126
|
+
const lons = corners.map((c) => c[0]);
|
|
127
|
+
const lats = corners.map((c) => c[1]);
|
|
128
|
+
const west = Math.min(...lons);
|
|
129
|
+
const south = Math.min(...lats);
|
|
130
|
+
const east = Math.max(...lons);
|
|
131
|
+
const north = Math.max(...lats);
|
|
132
|
+
// Return bounds in MapLibre format: [[west, south], [east, north]]
|
|
133
|
+
return { west, south, east, north };
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=geotiff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geotiff.js","sourceRoot":"","sources":["../src/geotiff.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAG7C,OAAO,EACL,UAAU,EACV,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,IAAI,GACL,MAAM,SAAS,CAAC;AAiBjB;;;;GAIG;AACH,IAAI,YAAY,GAAgB,IAAI,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAmB,EACnB,OAA2B;IAE3B,MAAM,aAAa,GAAG;QACpB,GAAG,OAAO;QACV,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;KAClB,CAAC;IACF,uEAAuE;IACvE,kDAAkD;IAClD,qDAAqD;IACrD,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,OAAO,CACnC,aAAa,CACd,CAA6B,CAAC;IAC/B,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO;QACL,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,KAAK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AAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAEhC,mEAAmE;IACnE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
export type { COGLayerProps } from "./cog-layer.js";
|
|
2
2
|
export { COGLayer } from "./cog-layer.js";
|
|
3
|
-
export { parseCOGTileMatrixSet } from "./cog-tile-matrix-set.js";
|
|
4
|
-
export { loadRgbImage, parseColormap } from "./geotiff/geotiff.js";
|
|
5
3
|
export * as texture from "./geotiff/texture.js";
|
|
6
|
-
export type { GeoTIFFLayerProps } from "./geotiff-layer.js";
|
|
7
|
-
export { GeoTIFFLayer } from "./geotiff-layer.js";
|
|
8
|
-
export { extractGeotiffReprojectors, fromGeoTransform, } from "./geotiff-reprojection.js";
|
|
9
4
|
export type { MosaicLayerProps } from "./mosaic-layer/mosaic-layer.js";
|
|
10
5
|
export { MosaicLayer } from "./mosaic-layer/mosaic-layer.js";
|
|
11
6
|
export { type MosaicSource, MosaicTileset2D, } from "./mosaic-layer/mosaic-tileset-2d";
|
|
12
7
|
export * as proj from "./proj.js";
|
|
13
|
-
export declare const __TEST_EXPORTS: {
|
|
14
|
-
metersPerUnit: (parsedCrs: import("proj4").ProjectionDefinition, crsUnit?: import("./proj.js").SupportedCrsUnit) => number;
|
|
15
|
-
};
|
|
16
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAIhD,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACL,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
export { COGLayer } from "./cog-layer.js";
|
|
2
|
-
export { parseCOGTileMatrixSet } from "./cog-tile-matrix-set.js";
|
|
3
|
-
export { loadRgbImage, parseColormap } from "./geotiff/geotiff.js";
|
|
4
2
|
export * as texture from "./geotiff/texture.js";
|
|
5
|
-
export { GeoTIFFLayer } from "./geotiff-layer.js";
|
|
6
|
-
export { extractGeotiffReprojectors, fromGeoTransform, } from "./geotiff-reprojection.js";
|
|
7
3
|
export { MosaicLayer } from "./mosaic-layer/mosaic-layer.js";
|
|
8
4
|
export { MosaicTileset2D, } from "./mosaic-layer/mosaic-tileset-2d";
|
|
9
5
|
export * as proj from "./proj.js";
|
|
10
|
-
import { __TEST_EXPORTS as cogTileMatrixSetTestExports } from "./cog-tile-matrix-set.js";
|
|
11
|
-
export const __TEST_EXPORTS = { ...cogTileMatrixSetTestExports };
|
|
12
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAKhD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAEL,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=mosaic-tile-traversal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-tile-traversal.d.ts","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-tile-traversal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-tile-traversal.js","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-tile-traversal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=mosaic-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-layer.d.ts","sourceRoot":"","sources":["../src/mosaic-layer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-layer.js","sourceRoot":"","sources":["../src/mosaic-layer.ts"],"names":[],"mappings":""}
|
package/dist/proj.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
import type { ProjectionDefinition } from "
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export interface ProjectionInfo {
|
|
5
|
-
/** Proj4-compatible projection definition (PROJJSON or proj4 string) */
|
|
6
|
-
def: string | PROJJSONDefinition;
|
|
7
|
-
/** A parsed projection definition */
|
|
8
|
-
parsed: ProjectionDefinition;
|
|
9
|
-
/** Units of the coordinate system */
|
|
10
|
-
coordinatesUnits: SupportedCrsUnit;
|
|
11
|
-
}
|
|
12
|
-
export type GeoKeysParser = (geoKeys: Record<string, any>) => Promise<ProjectionInfo | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Get the Projection of a GeoTIFF
|
|
15
|
-
*
|
|
16
|
-
* The first `image` must be passed in, as only the top-level IFD contains geo
|
|
17
|
-
* keys.
|
|
18
|
-
*/
|
|
19
|
-
export declare function epsgIoGeoKeyParser(geoKeys: Record<string, any>): Promise<ProjectionInfo | null>;
|
|
20
|
-
/**
|
|
21
|
-
* Parse a proj4-accepted input into a ProjectionDefinition
|
|
22
|
-
*/
|
|
23
|
-
export declare function parseCrs(crs: string | PROJJSONDefinition): ProjectionDefinition;
|
|
1
|
+
import type { ProjectionDefinition } from "wkt-parser";
|
|
2
|
+
export type EpsgResolver = (epsg: number) => Promise<ProjectionDefinition>;
|
|
3
|
+
export declare function epsgResolver(epsg: number): Promise<ProjectionDefinition>;
|
|
24
4
|
//# sourceMappingURL=proj.d.ts.map
|
package/dist/proj.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proj.d.ts","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proj.d.ts","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQvD,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE3E,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,iCAc9C"}
|
package/dist/proj.js
CHANGED
|
@@ -1,46 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import wktParser from "wkt-parser";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* The first `image` must be passed in, as only the top-level IFD contains geo
|
|
6
|
-
* keys.
|
|
3
|
+
* A global registry holding parsed projection definitions.
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const PROJECTION_REGISTRY = new Map();
|
|
6
|
+
export async function epsgResolver(epsg) {
|
|
7
|
+
const key = `EPSG:${epsg}`;
|
|
8
|
+
// TODO: override global proj4 EPSG:4326 definition because it doesn't include
|
|
9
|
+
// semi major axis
|
|
10
|
+
const cachedProj = PROJECTION_REGISTRY.get(key);
|
|
11
|
+
if (cachedProj !== undefined) {
|
|
12
|
+
return cachedProj;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
coordinatesUnits: parsed.units,
|
|
19
|
-
};
|
|
14
|
+
const projjson = await getProjjson(epsg);
|
|
15
|
+
const proj = wktParser(projjson);
|
|
16
|
+
PROJECTION_REGISTRY.set(key, proj);
|
|
17
|
+
return proj;
|
|
20
18
|
}
|
|
21
19
|
/** Query epsg.io for the PROJJSON corresponding to the given EPSG code. */
|
|
22
|
-
async function getProjjson(
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
async function getProjjson(epsg) {
|
|
21
|
+
const url = `https://epsg.io/${epsg}.json`;
|
|
22
|
+
const resp = await fetch(url);
|
|
23
|
+
if (!resp.ok) {
|
|
24
|
+
throw new Error(`Failed to fetch PROJJSON from ${url}`);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
const response = await fetch(url);
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
throw new Error(`Failed to fetch projection data from ${url}`);
|
|
30
|
-
}
|
|
31
|
-
const data = await response.json();
|
|
32
|
-
return data;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Parse a proj4-accepted input into a ProjectionDefinition
|
|
36
|
-
*/
|
|
37
|
-
export function parseCrs(crs) {
|
|
38
|
-
// If you pass proj4.defs a projjson, it doesn't parse it; it just returns the
|
|
39
|
-
// input.
|
|
40
|
-
//
|
|
41
|
-
// Instead, you need to assign it to an alias and then retrieve it.
|
|
42
|
-
const key = "__deck.gl-geotiff-internal__";
|
|
43
|
-
proj4.defs(key, crs);
|
|
44
|
-
return proj4.defs(key);
|
|
26
|
+
return await resp.json();
|
|
45
27
|
}
|
|
46
28
|
//# sourceMappingURL=proj.js.map
|
package/dist/proj.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proj.js","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proj.js","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAgC,CAAC;AAIpE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,MAAM,GAAG,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC3B,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2EAA2E;AAC3E,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,MAAM,GAAG,GAAG,mBAAmB,IAAI,OAAO,CAAC;IAC3C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TextureProps } from "@luma.gl/core";
|
|
2
|
+
import type { GeoTIFFImage, TypedArray } from "geotiff";
|
|
3
|
+
/**
|
|
4
|
+
* Infers texture properties from a GeoTIFF image and its associated data.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTextureProps(image: GeoTIFFImage, data: TypedArray, options: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}): TextureProps;
|
|
10
|
+
//# sourceMappingURL=texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../src/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGxD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC,YAAY,CAiBd"}
|