@developmentseed/deck.gl-geotiff 0.1.0-beta.5 → 0.1.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/cog-layer.d.ts +107 -9
- package/dist/cog-layer.d.ts.map +1 -1
- package/dist/cog-layer.js +122 -95
- package/dist/cog-layer.js.map +1 -1
- package/dist/cog-tile-matrix-set.d.ts +2 -1
- package/dist/cog-tile-matrix-set.d.ts.map +1 -1
- package/dist/cog-tile-matrix-set.js +20 -23
- package/dist/cog-tile-matrix-set.js.map +1 -1
- package/dist/ellipsoids.d.ts +1 -1
- package/dist/ellipsoids.js +1 -1
- package/dist/geotiff/geotiff.d.ts +59 -0
- package/dist/geotiff/geotiff.d.ts.map +1 -0
- package/dist/geotiff/geotiff.js +146 -0
- package/dist/geotiff/geotiff.js.map +1 -0
- package/dist/geotiff/index.d.ts +1 -0
- package/dist/geotiff/index.d.ts.map +1 -0
- package/dist/geotiff/index.js +2 -0
- package/dist/geotiff/index.js.map +1 -0
- package/dist/geotiff/render-pipeline.d.ts +13 -0
- package/dist/geotiff/render-pipeline.d.ts.map +1 -0
- package/dist/geotiff/render-pipeline.js +149 -0
- package/dist/geotiff/render-pipeline.js.map +1 -0
- package/dist/geotiff/texture.d.ts +14 -0
- package/dist/geotiff/texture.d.ts.map +1 -0
- package/dist/geotiff/texture.js +134 -0
- package/dist/geotiff/texture.js.map +1 -0
- package/dist/geotiff/types.d.ts +34 -0
- package/dist/geotiff/types.d.ts.map +1 -0
- package/dist/geotiff/types.js +18 -0
- package/dist/geotiff/types.js.map +1 -0
- package/dist/geotiff-layer.d.ts +42 -3
- package/dist/geotiff-layer.d.ts.map +1 -1
- package/dist/geotiff-layer.js +21 -7
- package/dist/geotiff-layer.js.map +1 -1
- package/dist/geotiff-reprojection.d.ts +5 -11
- package/dist/geotiff-reprojection.d.ts.map +1 -1
- package/dist/geotiff-reprojection.js +8 -37
- package/dist/geotiff-reprojection.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/proj.d.ts +24 -0
- package/dist/proj.d.ts.map +1 -0
- package/dist/proj.js +46 -0
- package/dist/proj.js.map +1 -0
- package/package.json +10 -15
- package/dist/geotiff.d.ts +0 -31
- package/dist/geotiff.d.ts.map +0 -1
- package/dist/geotiff.js +0 -70
- package/dist/geotiff.js.map +0 -1
- package/dist/index.cjs +0 -181
- package/dist/index.cjs.map +0 -1
- package/dist/pool.d.ts +0 -1
- package/dist/pool.d.ts.map +0 -1
- package/dist/pool.js +0 -2
- package/dist/pool.js.map +0 -1
- package/dist/src/geotiff-reprojection.d.ts +0 -10
- package/dist/src/geotiff-reprojection.d.ts.map +0 -1
- package/dist/src/geotiff-reprojection.js +0 -159
- package/dist/src/geotiff-reprojection.js.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/tests/placeholder.test.d.ts +0 -2
- package/dist/tests/placeholder.test.d.ts.map +0 -1
- package/dist/tests/placeholder.test.js +0 -7
- package/dist/tests/placeholder.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/geotiff-layer.d.ts
CHANGED
|
@@ -2,9 +2,29 @@ import type { CompositeLayerProps, UpdateParameters } from "@deck.gl/core";
|
|
|
2
2
|
import { CompositeLayer } from "@deck.gl/core";
|
|
3
3
|
import { RasterLayer } from "@developmentseed/deck.gl-raster";
|
|
4
4
|
import type { ReprojectionFns } from "@developmentseed/raster-reproject";
|
|
5
|
-
import type { GeoTIFF, Pool } from "geotiff";
|
|
5
|
+
import type { BaseClient, GeoTIFF, Pool } from "geotiff";
|
|
6
|
+
import type { GeoKeysParser, ProjectionInfo } from "./proj.js";
|
|
7
|
+
import { epsgIoGeoKeyParser } from "./proj.js";
|
|
6
8
|
export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
7
|
-
|
|
9
|
+
/**
|
|
10
|
+
* GeoTIFF input.
|
|
11
|
+
*
|
|
12
|
+
* - URL string pointing to a GeoTIFF
|
|
13
|
+
* - ArrayBuffer containing the GeoTIFF data
|
|
14
|
+
* - Blob containing the GeoTIFF data
|
|
15
|
+
* - An instance of GeoTIFF.js's GeoTIFF class
|
|
16
|
+
* - An instance of GeoTIFF.js's BaseClient for custom fetching
|
|
17
|
+
*/
|
|
18
|
+
geotiff: GeoTIFF | string | ArrayBuffer | Blob | BaseClient;
|
|
19
|
+
/**
|
|
20
|
+
* A function callback for parsing GeoTIFF geo keys to a Proj4 compatible
|
|
21
|
+
* definition.
|
|
22
|
+
*
|
|
23
|
+
* By default, uses epsg.io to resolve EPSG codes found in the GeoTIFF.
|
|
24
|
+
* Alternatively, you may want to use `geotiff-geokeys-to-proj4`, which is
|
|
25
|
+
* more extensive but adds 1.5MB to your bundle size.
|
|
26
|
+
*/
|
|
27
|
+
geoKeysParser?: GeoKeysParser;
|
|
8
28
|
/**
|
|
9
29
|
* GeoTIFF.js Pool for decoding image chunks.
|
|
10
30
|
*
|
|
@@ -28,6 +48,25 @@ export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
|
28
48
|
* @default 0.5
|
|
29
49
|
*/
|
|
30
50
|
debugOpacity?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Called when the GeoTIFF metadata has been loaded and parsed.
|
|
53
|
+
*
|
|
54
|
+
* @param {GeoTIFF} geotiff
|
|
55
|
+
* @param {ProjectionInfo} projection
|
|
56
|
+
*/
|
|
57
|
+
onGeoTIFFLoad?: (geotiff: GeoTIFF, options: {
|
|
58
|
+
projection: ProjectionInfo;
|
|
59
|
+
/**
|
|
60
|
+
* Bounds of the image in geographic coordinates (WGS84) [minLon, minLat,
|
|
61
|
+
* maxLon, maxLat]
|
|
62
|
+
*/
|
|
63
|
+
geographicBounds: {
|
|
64
|
+
west: number;
|
|
65
|
+
south: number;
|
|
66
|
+
east: number;
|
|
67
|
+
north: number;
|
|
68
|
+
};
|
|
69
|
+
}) => void;
|
|
31
70
|
}
|
|
32
71
|
/**
|
|
33
72
|
* GeoTIFFLayer renders a GeoTIFF file from an arbitrary projection.
|
|
@@ -39,7 +78,7 @@ export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
|
39
78
|
export declare class GeoTIFFLayer extends CompositeLayer<GeoTIFFLayerProps> {
|
|
40
79
|
static layerName: string;
|
|
41
80
|
static defaultProps: {
|
|
42
|
-
|
|
81
|
+
geoKeysParser: typeof epsgIoGeoKeyParser;
|
|
43
82
|
};
|
|
44
83
|
state: {
|
|
45
84
|
reprojectionFns?: ReprojectionFns;
|
|
@@ -1 +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;
|
|
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,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;A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IAAI,CAAC;IAsCpC,YAAY;CAsBb"}
|
package/dist/geotiff-layer.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CompositeLayer } from "@deck.gl/core";
|
|
2
2
|
import { RasterLayer } from "@developmentseed/deck.gl-raster";
|
|
3
|
+
import proj4 from "proj4";
|
|
4
|
+
import { defaultPool, fetchGeoTIFF, getGeographicBounds, loadRgbImage, } from "./geotiff/geotiff.js";
|
|
3
5
|
import { extractGeotiffReprojectors } from "./geotiff-reprojection.js";
|
|
4
|
-
import {
|
|
5
|
-
const DEFAULT_MAX_ERROR = 0.125;
|
|
6
|
+
import { epsgIoGeoKeyParser } from "./proj.js";
|
|
6
7
|
const defaultProps = {
|
|
7
|
-
|
|
8
|
+
geoKeysParser: epsgIoGeoKeyParser,
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* GeoTIFFLayer renders a GeoTIFF file from an arbitrary projection.
|
|
@@ -30,15 +31,28 @@ export class GeoTIFFLayer extends CompositeLayer {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
async _parseGeoTIFF() {
|
|
33
|
-
const
|
|
34
|
-
const reprojectionFns = await extractGeotiffReprojectors(geotiff);
|
|
34
|
+
const geotiff = await fetchGeoTIFF(this.props.geotiff);
|
|
35
35
|
const image = await geotiff.getImage();
|
|
36
|
-
const
|
|
36
|
+
const geoKeysParser = this.props.geoKeysParser;
|
|
37
|
+
const sourceProjection = await geoKeysParser(image.getGeoKeys());
|
|
38
|
+
if (!sourceProjection) {
|
|
39
|
+
throw new Error("Could not determine source projection from GeoTIFF geo keys");
|
|
40
|
+
}
|
|
41
|
+
const converter = proj4(sourceProjection.def, "EPSG:4326");
|
|
42
|
+
if (this.props.onGeoTIFFLoad) {
|
|
43
|
+
const geographicBounds = getGeographicBounds(image, converter);
|
|
44
|
+
this.props.onGeoTIFFLoad(geotiff, {
|
|
45
|
+
projection: sourceProjection,
|
|
46
|
+
geographicBounds,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const reprojectionFns = await extractGeotiffReprojectors(geotiff, sourceProjection.def);
|
|
50
|
+
const { texture, height, width } = await loadRgbImage(image, {
|
|
37
51
|
pool: this.props.pool || defaultPool(),
|
|
38
52
|
});
|
|
39
53
|
this.setState({
|
|
40
54
|
reprojectionFns,
|
|
41
|
-
imageData,
|
|
55
|
+
imageData: texture,
|
|
42
56
|
height,
|
|
43
57
|
width,
|
|
44
58
|
});
|
|
@@ -1 +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,
|
|
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,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA2E/C,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE,kBAAkB;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,cAAiC;IACjE,MAAM,CAAU,SAAS,GAAG,cAAc,CAAC;IAC3C,MAAM,CAAU,YAAY,GAAG,YAAY,CAAC;IASnC,eAAe;QACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IAEQ,WAAW,CAAC,MAA8B;QACjD,KAA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,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE;YAC3D,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,WAAW,EAAE;SACvC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC;YACZ,eAAe;YACf,SAAS,EAAE,OAAO;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;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"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import type { GeoTIFF, GeoTIFFImage } from "geotiff";
|
|
2
1
|
import type { ReprojectionFns } from "@developmentseed/raster-reproject";
|
|
2
|
+
import type { GeoTIFF, GeoTIFFImage } from "geotiff";
|
|
3
3
|
import type { PROJJSONDefinition } from "proj4/dist/lib/core";
|
|
4
4
|
import type Projection from "proj4/dist/lib/Proj";
|
|
5
|
-
export declare
|
|
5
|
+
export declare const OGC_84: PROJJSONDefinition;
|
|
6
|
+
export declare function extractGeotiffReprojectors(tiff: GeoTIFF, sourceProjection: string | PROJJSONDefinition, outputCrs?: string | PROJJSONDefinition | Projection): Promise<ReprojectionFns>;
|
|
6
7
|
export declare function fromGeoTransform(geotransform: [number, number, number, number, number, number]): {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
forwardTransform: (x: number, y: number) => [number, number];
|
|
9
|
+
inverseTransform: (x: number, y: number) => [number, number];
|
|
9
10
|
};
|
|
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
11
|
/**
|
|
18
12
|
* Extract affine geotransform from a GeoTIFF image.
|
|
19
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotiff-reprojection.d.ts","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"geotiff-reprojection.d.ts","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAKzE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,eAAO,MAAM,MAAM,EAAE,kBAuEpB,CAAC;AAMF,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,EACb,gBAAgB,EAAE,MAAM,GAAG,kBAAkB,EAC7C,SAAS,GAAE,MAAM,GAAG,kBAAkB,GAAG,UAAmB,GAC3D,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAC7D;IACD,gBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7D,gBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9D,CAOA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,GAClB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAiClD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
|
-
import { applyAffine, invertGeoTransform, } from "@developmentseed/raster-reproject";
|
|
2
|
+
import { applyAffine, invertGeoTransform, } from "@developmentseed/raster-reproject/affine";
|
|
3
3
|
import proj4 from "proj4";
|
|
4
|
-
const OGC_84 = {
|
|
4
|
+
export const OGC_84 = {
|
|
5
5
|
$schema: "https://proj.org/schemas/v0.7/projjson.schema.json",
|
|
6
6
|
type: "GeographicCRS",
|
|
7
7
|
name: "WGS 84 (CRS84)",
|
|
@@ -77,20 +77,16 @@ const OGC_84 = {
|
|
|
77
77
|
// https://github.com/developmentseed/lonboard/blob/35a1f3d691604ad9e083bf10a4bfde4158171486/src/cog-tileset/claude-tileset-2d-improved.ts#L141
|
|
78
78
|
//
|
|
79
79
|
// TODO: return a RasterReprojector instance, given the IFD and tile of interest?
|
|
80
|
-
export async function extractGeotiffReprojectors(tiff, outputCrs = OGC_84) {
|
|
80
|
+
export async function extractGeotiffReprojectors(tiff, sourceProjection, outputCrs = OGC_84) {
|
|
81
81
|
const image = await tiff.getImage();
|
|
82
82
|
// Extract geotransform from full-resolution image
|
|
83
83
|
// Only the top-level IFD has geo keys, so we'll derive overviews from this
|
|
84
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
85
|
const converter = proj4(sourceProjection, outputCrs);
|
|
90
|
-
const {
|
|
86
|
+
const { forwardTransform, inverseTransform } = fromGeoTransform(baseGeotransform);
|
|
91
87
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
forwardTransform,
|
|
89
|
+
inverseTransform,
|
|
94
90
|
forwardReproject: (x, y) => converter.forward([x, y], false),
|
|
95
91
|
inverseReproject: (x, y) => converter.inverse([x, y], false),
|
|
96
92
|
};
|
|
@@ -98,35 +94,10 @@ export async function extractGeotiffReprojectors(tiff, outputCrs = OGC_84) {
|
|
|
98
94
|
export function fromGeoTransform(geotransform) {
|
|
99
95
|
const inverseGeotransform = invertGeoTransform(geotransform);
|
|
100
96
|
return {
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
forwardTransform: (x, y) => applyAffine(x, y, geotransform),
|
|
98
|
+
inverseTransform: (x, y) => applyAffine(x, y, inverseGeotransform),
|
|
103
99
|
};
|
|
104
100
|
}
|
|
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
101
|
/**
|
|
131
102
|
* Extract affine geotransform from a GeoTIFF image.
|
|
132
103
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,wBAAwB;
|
|
1
|
+
{"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAGxB,OAAO,EACL,WAAW,EACX,kBAAkB,GACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,OAAO,EAAE,oDAAoD;IAC7D,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,gBAAgB;IACtB,cAAc,EAAE;QACd,IAAI,EAAE,qCAAqC;QAC3C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,sCAAsC;gBAC5C,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;aACtC;YACD;gBACE,IAAI,EAAE,mCAAmC;gBACzC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;aACtC;YACD;gBACE,IAAI,EAAE,mCAAmC;gBACzC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;aACtC;YACD;gBACE,IAAI,EAAE,oCAAoC;gBAC1C,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;aACtC;YACD;gBACE,IAAI,EAAE,oCAAoC;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,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export { COGLayer } from "./cog-layer.js";
|
|
2
1
|
export type { COGLayerProps } from "./cog-layer.js";
|
|
2
|
+
export { COGLayer } from "./cog-layer.js";
|
|
3
3
|
export { parseCOGTileMatrixSet } from "./cog-tile-matrix-set.js";
|
|
4
|
-
export {
|
|
4
|
+
export { loadRgbImage, parseColormap } from "./geotiff/geotiff.js";
|
|
5
|
+
export * as texture from "./geotiff/texture.js";
|
|
5
6
|
export type { GeoTIFFLayerProps } from "./geotiff-layer.js";
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
7
|
+
export { GeoTIFFLayer } from "./geotiff-layer.js";
|
|
8
|
+
export { extractGeotiffReprojectors, fromGeoTransform, } from "./geotiff-reprojection.js";
|
|
9
|
+
export * as proj from "./proj.js";
|
|
8
10
|
//# 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,
|
|
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,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { COGLayer } from "./cog-layer.js";
|
|
2
2
|
export { parseCOGTileMatrixSet } from "./cog-tile-matrix-set.js";
|
|
3
|
+
export { loadRgbImage, parseColormap } from "./geotiff/geotiff.js";
|
|
4
|
+
export * as texture from "./geotiff/texture.js";
|
|
3
5
|
export { GeoTIFFLayer } from "./geotiff-layer.js";
|
|
4
|
-
export { extractGeotiffReprojectors, fromGeoTransform,
|
|
5
|
-
export
|
|
6
|
+
export { extractGeotiffReprojectors, fromGeoTransform, } from "./geotiff-reprojection.js";
|
|
7
|
+
export * as proj from "./proj.js";
|
|
6
8
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
package/dist/proj.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ProjectionDefinition } from "proj4";
|
|
2
|
+
import type { PROJJSONDefinition } from "proj4/dist/lib/core";
|
|
3
|
+
export type SupportedCrsUnit = "metre" | "meter" | "meters" | "foot" | "US survey foot" | "degree";
|
|
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;
|
|
24
|
+
//# sourceMappingURL=proj.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proj.d.ts","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,gBAAgB,GAChB,QAAQ,CAAC;AAEb,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC;IACjC,qCAAqC;IACrC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,qCAAqC;IACrC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACzB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;AAEpC;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAgBhC;AAiBD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAC/B,oBAAoB,CAStB"}
|
package/dist/proj.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import proj4 from "proj4";
|
|
2
|
+
/**
|
|
3
|
+
* Get the Projection of a GeoTIFF
|
|
4
|
+
*
|
|
5
|
+
* The first `image` must be passed in, as only the top-level IFD contains geo
|
|
6
|
+
* keys.
|
|
7
|
+
*/
|
|
8
|
+
export async function epsgIoGeoKeyParser(geoKeys) {
|
|
9
|
+
const projectionCode = geoKeys.ProjectedCSTypeGeoKey || geoKeys.GeographicTypeGeoKey || null;
|
|
10
|
+
const sourceProjection = await getProjjson(projectionCode);
|
|
11
|
+
if (!sourceProjection) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const parsed = parseCrs(sourceProjection);
|
|
15
|
+
return {
|
|
16
|
+
def: sourceProjection,
|
|
17
|
+
parsed,
|
|
18
|
+
coordinatesUnits: parsed.units,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Query epsg.io for the PROJJSON corresponding to the given EPSG code. */
|
|
22
|
+
async function getProjjson(projectionCode) {
|
|
23
|
+
if (projectionCode === null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const url = `https://epsg.io/${projectionCode}.json`;
|
|
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);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=proj.js.map
|
package/dist/proj.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proj.js","sourceRoot":"","sources":["../src/proj.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;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 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developmentseed/deck.gl-geotiff",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "GeoTIFF and Cloud-Optimized GeoTIFF visualization in deck.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"sideEffects": false,
|
|
14
15
|
"files": [
|
|
15
16
|
"dist"
|
|
16
17
|
],
|
|
@@ -32,26 +33,23 @@
|
|
|
32
33
|
"url": "git+https://github.com/developmentseed/deck.gl-raster.git"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^25.0.
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"jsdom": "^27.2.0",
|
|
40
|
-
"prettier": "^3.3.3",
|
|
41
|
-
"typescript": "^5.7.2",
|
|
42
|
-
"vitest": "^4.0.15"
|
|
36
|
+
"@types/node": "^25.0.3",
|
|
37
|
+
"jsdom": "^27.4.0",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^4.0.16"
|
|
43
40
|
},
|
|
44
41
|
"dependencies": {
|
|
45
42
|
"geotiff": "2.1.3",
|
|
46
43
|
"proj4": "^2.20.2",
|
|
47
|
-
"@developmentseed/
|
|
48
|
-
"@developmentseed/raster
|
|
44
|
+
"@developmentseed/raster-reproject": "^0.1.0",
|
|
45
|
+
"@developmentseed/deck.gl-raster": "^0.1.0"
|
|
49
46
|
},
|
|
50
47
|
"peerDependencies": {
|
|
51
48
|
"@deck.gl/core": "^9.2.5",
|
|
52
49
|
"@deck.gl/geo-layers": "^9.2.5",
|
|
53
50
|
"@deck.gl/layers": "^9.2.5",
|
|
54
|
-
"@deck.gl/mesh-layers": "^9.2.5"
|
|
51
|
+
"@deck.gl/mesh-layers": "^9.2.5",
|
|
52
|
+
"@luma.gl/core": "^9.2.5"
|
|
55
53
|
},
|
|
56
54
|
"volta": {
|
|
57
55
|
"extends": "../../package.json"
|
|
@@ -60,9 +58,6 @@
|
|
|
60
58
|
"build": "tsc --build tsconfig.build.json",
|
|
61
59
|
"test": "vitest run",
|
|
62
60
|
"test:watch": "vitest",
|
|
63
|
-
"lint": "eslint src --ext .ts,.tsx",
|
|
64
|
-
"format": "prettier --write \"src/**/*.{ts,tsx,json}\"",
|
|
65
|
-
"format:check": "prettier --check \"src/**/*.{ts,tsx,json}\"",
|
|
66
61
|
"typecheck": "tsc --noEmit"
|
|
67
62
|
}
|
|
68
63
|
}
|
package/dist/geotiff.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
package/dist/geotiff.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/geotiff.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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
|
package/dist/geotiff.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAA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