@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.
Files changed (49) hide show
  1. package/README.md +6 -0
  2. package/dist/cog-layer.d.ts +53 -0
  3. package/dist/cog-layer.d.ts.map +1 -0
  4. package/dist/cog-layer.js +178 -0
  5. package/dist/cog-layer.js.map +1 -0
  6. package/dist/cog-tile-matrix-set.d.ts +11 -0
  7. package/dist/cog-tile-matrix-set.d.ts.map +1 -0
  8. package/dist/cog-tile-matrix-set.js +179 -0
  9. package/dist/cog-tile-matrix-set.js.map +1 -0
  10. package/dist/ellipsoids.d.ts +153 -0
  11. package/dist/ellipsoids.d.ts.map +1 -0
  12. package/dist/ellipsoids.js +153 -0
  13. package/dist/ellipsoids.js.map +1 -0
  14. package/dist/geotiff-layer.d.ts +55 -0
  15. package/dist/geotiff-layer.d.ts.map +1 -0
  16. package/dist/geotiff-layer.js +64 -0
  17. package/dist/geotiff-layer.js.map +1 -0
  18. package/dist/geotiff-reprojection.d.ts +31 -0
  19. package/dist/geotiff-reprojection.d.ts.map +1 -0
  20. package/dist/geotiff-reprojection.js +172 -0
  21. package/dist/geotiff-reprojection.js.map +1 -0
  22. package/dist/geotiff.d.ts +31 -0
  23. package/dist/geotiff.d.ts.map +1 -0
  24. package/dist/geotiff.js +70 -0
  25. package/dist/geotiff.js.map +1 -0
  26. package/dist/index.cjs +181 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.ts +8 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +6 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/pool.d.ts +1 -0
  33. package/dist/pool.d.ts.map +1 -0
  34. package/dist/pool.js +2 -0
  35. package/dist/pool.js.map +1 -0
  36. package/dist/src/geotiff-reprojection.d.ts +10 -0
  37. package/dist/src/geotiff-reprojection.d.ts.map +1 -0
  38. package/dist/src/geotiff-reprojection.js +159 -0
  39. package/dist/src/geotiff-reprojection.js.map +1 -0
  40. package/dist/src/index.d.ts +2 -0
  41. package/dist/src/index.d.ts.map +1 -0
  42. package/dist/src/index.js +2 -0
  43. package/dist/src/index.js.map +1 -0
  44. package/dist/tests/placeholder.test.d.ts +2 -0
  45. package/dist/tests/placeholder.test.d.ts.map +1 -0
  46. package/dist/tests/placeholder.test.js +7 -0
  47. package/dist/tests/placeholder.test.js.map +1 -0
  48. package/dist/tsconfig.tsbuildinfo +1 -0
  49. package/package.json +69 -0
@@ -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
+ const ellipsoids = {
11
+ MERIT: {
12
+ a: 6378137,
13
+ },
14
+ SGS85: {
15
+ a: 6378136,
16
+ },
17
+ GRS80: {
18
+ a: 6378137,
19
+ },
20
+ IAU76: {
21
+ a: 6378140,
22
+ },
23
+ airy: {
24
+ a: 6377563.396,
25
+ b: 6356256.91,
26
+ },
27
+ APL4: {
28
+ a: 6378137,
29
+ },
30
+ NWL9D: {
31
+ a: 6378145,
32
+ },
33
+ mod_airy: {
34
+ a: 6377340.189,
35
+ b: 6356034.446,
36
+ },
37
+ andrae: {
38
+ a: 6377104.43,
39
+ },
40
+ aust_SA: {
41
+ a: 6378160,
42
+ },
43
+ GRS67: {
44
+ a: 6378160,
45
+ },
46
+ bessel: {
47
+ a: 6377397.155,
48
+ },
49
+ bess_nam: {
50
+ a: 6377483.865,
51
+ },
52
+ clrk66: {
53
+ a: 6378206.4,
54
+ b: 6356583.8,
55
+ },
56
+ clrk80: {
57
+ a: 6378249.145,
58
+ },
59
+ clrk80ign: {
60
+ a: 6378249.2,
61
+ b: 6356515,
62
+ },
63
+ clrk58: {
64
+ a: 6378293.645208759,
65
+ },
66
+ CPM: {
67
+ a: 6375738.7,
68
+ },
69
+ delmbr: {
70
+ a: 6376428,
71
+ },
72
+ engelis: {
73
+ a: 6378136.05,
74
+ },
75
+ evrst30: {
76
+ a: 6377276.345,
77
+ },
78
+ evrst48: {
79
+ a: 6377304.063,
80
+ },
81
+ evrst56: {
82
+ a: 6377301.243,
83
+ },
84
+ evrst69: {
85
+ a: 6377295.664,
86
+ },
87
+ evrstSS: {
88
+ a: 6377298.556,
89
+ },
90
+ fschr60: {
91
+ a: 6378166,
92
+ },
93
+ fschr60m: {
94
+ a: 6378155,
95
+ },
96
+ fschr68: {
97
+ a: 6378150,
98
+ },
99
+ helmert: {
100
+ a: 6378200,
101
+ },
102
+ hough: {
103
+ a: 6378270,
104
+ },
105
+ intl: {
106
+ a: 6378388,
107
+ },
108
+ kaula: {
109
+ a: 6378163,
110
+ },
111
+ lerch: {
112
+ a: 6378139,
113
+ },
114
+ mprts: {
115
+ a: 6397300,
116
+ },
117
+ new_intl: {
118
+ a: 6378157.5,
119
+ b: 6356772.2,
120
+ },
121
+ plessis: {
122
+ a: 6376523,
123
+ },
124
+ krass: {
125
+ a: 6378245,
126
+ },
127
+ SEasia: {
128
+ a: 6378155,
129
+ b: 6356773.3205,
130
+ },
131
+ walbeck: {
132
+ a: 6376896,
133
+ b: 6355834.8467,
134
+ },
135
+ WGS60: {
136
+ a: 6378165,
137
+ },
138
+ WGS66: {
139
+ a: 6378145,
140
+ },
141
+ WGS7: {
142
+ a: 6378135,
143
+ },
144
+ WGS84: {
145
+ a: 6378137,
146
+ },
147
+ sphere: {
148
+ a: 6370997,
149
+ b: 6370997,
150
+ },
151
+ };
152
+ export default ellipsoids;
153
+ //# sourceMappingURL=ellipsoids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipsoids.js","sourceRoot":"","sources":["../src/ellipsoids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,UA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AAO,EAAE;QACP,CAAC,EAAE,OAAO;KACX;IACD,QAAQ,EAAE;QACR,CAAC,EAAE,OAAO;KACX;IACD,OAAO,EAAE;QACP,CAAC,EAAE,OAAO;KACX;IACD,OAAO,EAAE;QACP,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,IAAI,EAAE;QACJ,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,QAAQ,EAAE;QACR,CAAC,EAAE,SAAS;QACZ,CAAC,EAAE,SAAS;KACb;IACD,OAAO,EAAE;QACP,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,MAAM,EAAE;QACN,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,YAAY;KAChB;IACD,OAAO,EAAE;QACP,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,YAAY;KAChB;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,IAAI,EAAE;QACJ,CAAC,EAAE,OAAO;KACX;IACD,KAAK,EAAE;QACL,CAAC,EAAE,OAAO;KACX;IACD,MAAM,EAAE;QACN,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,OAAO;KACX;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { CompositeLayerProps, UpdateParameters } from "@deck.gl/core";
2
+ import { CompositeLayer } from "@deck.gl/core";
3
+ import { RasterLayer } from "@developmentseed/deck.gl-raster";
4
+ import type { ReprojectionFns } from "@developmentseed/raster-reproject";
5
+ import type { GeoTIFF, Pool } from "geotiff";
6
+ export interface GeoTIFFLayerProps extends CompositeLayerProps {
7
+ geotiff: GeoTIFF;
8
+ /**
9
+ * GeoTIFF.js Pool for decoding image chunks.
10
+ *
11
+ * If none is provided, a default Pool will be created and shared between all
12
+ * COGLayer and GeoTIFFLayer instances.
13
+ */
14
+ pool?: Pool;
15
+ /**
16
+ * Maximum reprojection error in pixels for mesh refinement.
17
+ * Lower values create denser meshes with higher accuracy.
18
+ * @default 0.125
19
+ */
20
+ maxError?: number;
21
+ /**
22
+ * Enable debug visualization showing the triangulation mesh
23
+ * @default false
24
+ */
25
+ debug?: boolean;
26
+ /**
27
+ * Opacity of the debug mesh overlay (0-1)
28
+ * @default 0.5
29
+ */
30
+ debugOpacity?: number;
31
+ }
32
+ /**
33
+ * GeoTIFFLayer renders a GeoTIFF file from an arbitrary projection.
34
+ *
35
+ * The GeoTIFFLayer differs from the COGLayer in that it doesn't assume any
36
+ * internal tiling. Rather, it fetches the entire full-resolution image and
37
+ * displays it directly.
38
+ */
39
+ export declare class GeoTIFFLayer extends CompositeLayer<GeoTIFFLayerProps> {
40
+ static layerName: string;
41
+ static defaultProps: {
42
+ maxError: number;
43
+ };
44
+ state: {
45
+ reprojectionFns?: ReprojectionFns;
46
+ imageData?: ImageData;
47
+ height?: number;
48
+ width?: number;
49
+ };
50
+ initializeState(): void;
51
+ updateState(params: UpdateParameters<this>): void;
52
+ _parseGeoTIFF(): Promise<void>;
53
+ renderLayers(): RasterLayer | null;
54
+ }
55
+ //# sourceMappingURL=geotiff-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-layer.d.ts","sourceRoot":"","sources":["../src/geotiff-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAM7C,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACjE,OAAgB,SAAS,SAAkB;IAC3C,OAAgB,YAAY;;MAAgB;IAEpC,KAAK,EAAE;QACb,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAEO,eAAe,IAAI,IAAI;IAIvB,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAe7C,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBpC,YAAY;CAsBb"}
@@ -0,0 +1,64 @@
1
+ import { CompositeLayer } from "@deck.gl/core";
2
+ import { RasterLayer } from "@developmentseed/deck.gl-raster";
3
+ import { extractGeotiffReprojectors } from "./geotiff-reprojection.js";
4
+ import { defaultPool, loadRgbImage } from "./geotiff.js";
5
+ const DEFAULT_MAX_ERROR = 0.125;
6
+ const defaultProps = {
7
+ maxError: DEFAULT_MAX_ERROR,
8
+ };
9
+ /**
10
+ * GeoTIFFLayer renders a GeoTIFF file from an arbitrary projection.
11
+ *
12
+ * The GeoTIFFLayer differs from the COGLayer in that it doesn't assume any
13
+ * internal tiling. Rather, it fetches the entire full-resolution image and
14
+ * displays it directly.
15
+ */
16
+ export class GeoTIFFLayer extends CompositeLayer {
17
+ static layerName = "GeoTIFFLayer";
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) ||
26
+ props.geotiff !== oldProps.geotiff ||
27
+ props.maxError !== oldProps.maxError;
28
+ if (needsUpdate) {
29
+ this._parseGeoTIFF();
30
+ }
31
+ }
32
+ async _parseGeoTIFF() {
33
+ const { geotiff } = this.props;
34
+ const reprojectionFns = await extractGeotiffReprojectors(geotiff);
35
+ const image = await geotiff.getImage();
36
+ const { imageData, height, width } = await loadRgbImage(image, {
37
+ pool: this.props.pool || defaultPool(),
38
+ });
39
+ this.setState({
40
+ reprojectionFns,
41
+ imageData,
42
+ height,
43
+ width,
44
+ });
45
+ }
46
+ renderLayers() {
47
+ const { reprojectionFns, imageData, height, width } = this.state;
48
+ if (!reprojectionFns || !imageData || !height || !width) {
49
+ return null;
50
+ }
51
+ const { maxError, debug, debugOpacity } = this.props;
52
+ return new RasterLayer(this.getSubLayerProps({
53
+ id: "raster",
54
+ width,
55
+ height,
56
+ reprojectionFns,
57
+ maxError,
58
+ texture: imageData,
59
+ debug,
60
+ debugOpacity,
61
+ }));
62
+ }
63
+ }
64
+ //# sourceMappingURL=geotiff-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-layer.js","sourceRoot":"","sources":["../src/geotiff-layer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAiChC,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE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AAC;QAEjE,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAErD,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,gBAAgB,CAAC;YACpB,EAAE,EAAE,QAAQ;YACZ,KAAK;YACL,MAAM;YACN,eAAe;YACf,QAAQ;YACR,OAAO,EAAE,SAAS;YAClB,KAAK;YACL,YAAY;SACb,CAAC,CACH,CAAC;IACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { GeoTIFF, GeoTIFFImage } from "geotiff";
2
+ import type { ReprojectionFns } from "@developmentseed/raster-reproject";
3
+ import type { PROJJSONDefinition } from "proj4/dist/lib/core";
4
+ import type Projection from "proj4/dist/lib/Proj";
5
+ export declare function extractGeotiffReprojectors(tiff: GeoTIFF, outputCrs?: string | PROJJSONDefinition | Projection): Promise<ReprojectionFns>;
6
+ export declare function fromGeoTransform(geotransform: [number, number, number, number, number, number]): {
7
+ pixelToInputCRS: (x: number, y: number) => [number, number];
8
+ inputCRSToPixel: (x: number, y: number) => [number, number];
9
+ };
10
+ /**
11
+ * Get the Projection of a GeoTIFF
12
+ *
13
+ * The first `image` must be passed in, as only the top-level IFD contains geo
14
+ * keys.
15
+ */
16
+ export declare function getGeoTIFFProjection(image: GeoTIFFImage): Promise<PROJJSONDefinition | null>;
17
+ /**
18
+ * Extract affine geotransform from a GeoTIFF image.
19
+ *
20
+ * The first `image` must be passed in, as only the top-level IFD contains geo
21
+ * keys.
22
+ *
23
+ * Returns a 6-element array in Python `affine` package ordering:
24
+ * [a, b, c, d, e, f] where:
25
+ * - x_geo = a * col + b * row + c
26
+ * - y_geo = d * col + e * row + f
27
+ *
28
+ * This is NOT GDAL ordering, which is [c, a, b, f, d, e].
29
+ */
30
+ export declare function extractGeotransform(image: GeoTIFFImage): [number, number, number, number, number, number];
31
+ //# sourceMappingURL=geotiff-reprojection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-reprojection.d.ts","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAMzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AA+ElD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,EACb,SAAS,GAAE,MAAM,GAAG,kBAAkB,GAAG,UAAmB,GAC3D,OAAO,CAAC,eAAe,CAAC,CAyB1B;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAC7D;IACD,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7D,CAOA;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAOpC;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,GAClB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAiClD"}
@@ -0,0 +1,172 @@
1
+ /* eslint-env browser */
2
+ import { applyAffine, invertGeoTransform, } from "@developmentseed/raster-reproject";
3
+ import proj4 from "proj4";
4
+ 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
+ // Derived from existing work here:
77
+ // https://github.com/developmentseed/lonboard/blob/35a1f3d691604ad9e083bf10a4bfde4158171486/src/cog-tileset/claude-tileset-2d-improved.ts#L141
78
+ //
79
+ // TODO: return a RasterReprojector instance, given the IFD and tile of interest?
80
+ export async function extractGeotiffReprojectors(tiff, outputCrs = OGC_84) {
81
+ const image = await tiff.getImage();
82
+ // Extract geotransform from full-resolution image
83
+ // Only the top-level IFD has geo keys, so we'll derive overviews from this
84
+ const baseGeotransform = extractGeotransform(image);
85
+ const sourceProjection = await getGeoTIFFProjection(image);
86
+ if (sourceProjection === null) {
87
+ throw new Error("Could not determine source projection from GeoTIFF geo keys");
88
+ }
89
+ const converter = proj4(sourceProjection, outputCrs);
90
+ const { pixelToInputCRS, inputCRSToPixel } = fromGeoTransform(baseGeotransform);
91
+ return {
92
+ pixelToInputCRS,
93
+ inputCRSToPixel,
94
+ forwardReproject: (x, y) => converter.forward([x, y], false),
95
+ inverseReproject: (x, y) => converter.inverse([x, y], false),
96
+ };
97
+ }
98
+ export function fromGeoTransform(geotransform) {
99
+ const inverseGeotransform = invertGeoTransform(geotransform);
100
+ return {
101
+ pixelToInputCRS: (x, y) => applyAffine(x, y, geotransform),
102
+ inputCRSToPixel: (x, y) => applyAffine(x, y, inverseGeotransform),
103
+ };
104
+ }
105
+ /**
106
+ * Get the Projection of a GeoTIFF
107
+ *
108
+ * The first `image` must be passed in, as only the top-level IFD contains geo
109
+ * keys.
110
+ */
111
+ export async function getGeoTIFFProjection(image) {
112
+ const geoKeys = image.getGeoKeys();
113
+ const projectionCode = geoKeys.ProjectedCSTypeGeoKey || geoKeys.GeographicTypeGeoKey || null;
114
+ const sourceProjection = await getProjjson(projectionCode);
115
+ return sourceProjection;
116
+ }
117
+ /** Query epsg.io for the PROJJSON corresponding to the given EPSG code. */
118
+ async function getProjjson(projectionCode) {
119
+ if (projectionCode === null) {
120
+ return null;
121
+ }
122
+ const url = `https://epsg.io/${projectionCode}.json`;
123
+ const response = await fetch(url);
124
+ if (!response.ok) {
125
+ throw new Error(`Failed to fetch projection data from ${url}`);
126
+ }
127
+ const data = await response.json();
128
+ return data;
129
+ }
130
+ /**
131
+ * Extract affine geotransform from a GeoTIFF image.
132
+ *
133
+ * The first `image` must be passed in, as only the top-level IFD contains geo
134
+ * keys.
135
+ *
136
+ * Returns a 6-element array in Python `affine` package ordering:
137
+ * [a, b, c, d, e, f] where:
138
+ * - x_geo = a * col + b * row + c
139
+ * - y_geo = d * col + e * row + f
140
+ *
141
+ * This is NOT GDAL ordering, which is [c, a, b, f, d, e].
142
+ */
143
+ export function extractGeotransform(image) {
144
+ const origin = image.getOrigin();
145
+ const resolution = image.getResolution();
146
+ // origin: [x, y, z]
147
+ // resolution: [x_res, y_res, z_res]
148
+ // Check for rotation/skew in the file directory
149
+ const fileDirectory = image.getFileDirectory();
150
+ const modelTransformation = fileDirectory.ModelTransformation;
151
+ let b = 0; // row rotation
152
+ let d = 0; // column rotation
153
+ if (modelTransformation && modelTransformation.length >= 16) {
154
+ // ModelTransformation is a 4x4 matrix in row-major order
155
+ // [0 1 2 3 ] [a b 0 c]
156
+ // [4 5 6 7 ] = [d e 0 f]
157
+ // [8 9 10 11] [0 0 1 0]
158
+ // [12 13 14 15] [0 0 0 1]
159
+ b = modelTransformation[1];
160
+ d = modelTransformation[4];
161
+ }
162
+ // Return in affine package ordering: [a, b, c, d, e, f]
163
+ return [
164
+ resolution[0], // a: pixel width
165
+ b, // b: row rotation
166
+ origin[0], // c: x origin
167
+ d, // d: column rotation
168
+ resolution[1], // e: pixel height (often negative)
169
+ origin[1],
170
+ ];
171
+ }
172
+ //# sourceMappingURL=geotiff-reprojection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAIxB,OAAO,EACL,WAAW,EAC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,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAmB;IAEnB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;IAEzC,oBAAoB;IACpB,oCAAoC;IAEpC,gDAAgD;IAChD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC/C,MAAM,mBAAmB,GAAG,aAAa,CAAC,mBAAmB,CAAC;IAE9D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe;IAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,kBAAkB;IAE7B,IAAI,mBAAmB,IAAI,mBAAmB,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAC5D,yDAAyD;QACzD,+BAA+B;QAC/B,+BAA+B;QAC/B,+BAA+B;QAC/B,+BAA+B;QAC/B,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,wDAAwD;IACxD,OAAO;QACL,UAAU,CAAC,CAAC,CAAE,EAAE,iBAAiB;QACjC,CAAC,EAAE,kBAAkB;QACrB,MAAM,CAAC,CAAC,CAAE,EAAE,cAAc;QAC1B,CAAC,EAAE,qBAAqB;QACxB,UAAU,CAAC,CAAC,CAAE,EAAE,mCAAmC;QACnD,MAAM,CAAC,CAAC,CAAE;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { GeoTIFFImage } from "geotiff";
2
+ import { Pool } from "geotiff";
3
+ /**
4
+ * Options that may be passed when reading image data from geotiff.js
5
+ */
6
+ type ReadRasterOptions = {
7
+ /** the subset to read data from in pixels. */
8
+ window?: [number, number, number, number];
9
+ /** The optional decoder pool to use. */
10
+ pool?: Pool;
11
+ /** An AbortSignal that may be signalled if the request is to be aborted */
12
+ signal?: AbortSignal;
13
+ };
14
+ /**
15
+ * Retrieve the default geotiff.js decoder Pool.
16
+ *
17
+ * If a Pool has not yet been created, it will be created on first call.
18
+ *
19
+ * The Pool will be shared between all COGLayer and GeoTIFFLayer instances.
20
+ */
21
+ export declare function defaultPool(): Pool;
22
+ /**
23
+ * Load an RGBA image from a GeoTIFFImage.
24
+ */
25
+ export declare function loadRgbImage(image: GeoTIFFImage, options?: ReadRasterOptions): Promise<{
26
+ imageData: ImageData;
27
+ height: number;
28
+ width: number;
29
+ }>;
30
+ export {};
31
+ //# sourceMappingURL=geotiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff.d.ts","sourceRoot":"","sources":["../src/geotiff.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAA4B,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B;;GAEG;AACH,KAAK,iBAAiB,GAAG;IACvB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C,wCAAwC;IACxC,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AASF;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAMlC;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBlE"}
@@ -0,0 +1,70 @@
1
+ // Utilities for interacting with geotiff.js.
2
+ import { 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
+ 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
+ //# sourceMappingURL=geotiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geotiff.js","sourceRoot":"","sources":["../src/geotiff.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAG7C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAgB/B;;;;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,SAAS;QACT,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAkC;IACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG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