@developmentseed/deck.gl-geotiff 0.2.0 → 0.3.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/README.md +33 -4
- package/dist/cog-layer.d.ts +63 -57
- package/dist/cog-layer.d.ts.map +1 -1
- package/dist/cog-layer.js +116 -85
- package/dist/cog-layer.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 +34 -103
- package/dist/geotiff/geotiff.js.map +1 -1
- package/dist/geotiff/render-pipeline.d.ts +7 -5
- package/dist/geotiff/render-pipeline.d.ts.map +1 -1
- package/dist/geotiff/render-pipeline.js +152 -49
- 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-layer.d.ts +21 -24
- 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 +5 -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/index.d.ts +3 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- 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/package.json +16 -12
- package/dist/cog-tile-matrix-set.d.ts +0 -32
- package/dist/cog-tile-matrix-set.d.ts.map +0 -1
- package/dist/cog-tile-matrix-set.js +0 -180
- package/dist/cog-tile-matrix-set.js.map +0 -1
- package/dist/ellipsoids.d.ts +0 -153
- package/dist/ellipsoids.d.ts.map +0 -1
- package/dist/ellipsoids.js +0 -153
- package/dist/ellipsoids.js.map +0 -1
- package/dist/geotiff/types.d.ts +0 -34
- package/dist/geotiff/types.d.ts.map +0 -1
- package/dist/geotiff/types.js +0 -18
- package/dist/geotiff/types.js.map +0 -1
package/dist/geotiff/texture.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { SampleFormat } from "@cogeotiff/core";
|
|
1
2
|
/**
|
|
2
3
|
* Infers texture properties from a GeoTIFF image and its associated data.
|
|
3
4
|
*/
|
|
4
|
-
export function createTextureProps(
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const textureFormat = inferTextureFormat(samplesPerPixel, ifd.BitsPerSample, ifd.SampleFormat);
|
|
5
|
+
export function createTextureProps(geotiff, data, options) {
|
|
6
|
+
const { samplesPerPixel, bitsPerSample, sampleFormat } = geotiff.cachedTags;
|
|
7
|
+
const textureFormat = inferTextureFormat(samplesPerPixel, bitsPerSample, sampleFormat);
|
|
8
8
|
return {
|
|
9
9
|
data,
|
|
10
10
|
format: textureFormat,
|
|
@@ -60,11 +60,11 @@ function inferScalarKind(sampleFormat) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
switch (first) {
|
|
63
|
-
case
|
|
63
|
+
case SampleFormat.Uint:
|
|
64
64
|
return "unorm";
|
|
65
|
-
case
|
|
65
|
+
case SampleFormat.Int:
|
|
66
66
|
return "sint";
|
|
67
|
-
case
|
|
67
|
+
case SampleFormat.Float:
|
|
68
68
|
return "float";
|
|
69
69
|
default:
|
|
70
70
|
throw new Error(`Unsupported SampleFormat ${sampleFormat}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/geotiff/texture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/geotiff/texture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C;;GAEG;A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QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,SAAS;IAEtB,kCAAkC;IAClC,YAAY,EAAE,UAAU;IACxB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE,UAAU;IAExB,mCAAmC;IACnC,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,WAAW,EAAE,UAAU;IAEvB,kCAAkC;IAClC,YAAY,EAAE,UAAU;IACxB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IAEtB,mCAAmC;IACnC,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,WAAW;IAEzB,oCAAoC;IACpC,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;IACvB,WAAW,EAAE,YAAY;IAEzB,qCAAqC;IACrC,gEAAgE;IAChE,gEAAgE;IAChE,WAAW,EAAE,kBAAkB;IAE/B,mCAAmC;IACnC,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,UAAU;IAEvB,oCAAoC;IACpC,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,YAAY;IACzB,YAAY,EAAE,aAAa;IAE3B,sCAAsC;IACtC,YAAY,EAAE,kBAAkB;IAEhC,qCAAqC;IACrC,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,YAAY;CAC1B,CAAC"}
|
package/dist/geotiff-layer.d.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
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
|
+
import type { DecoderPool, GeoTIFF } from "@developmentseed/geotiff";
|
|
4
5
|
import type { ReprojectionFns } from "@developmentseed/raster-reproject";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
6
|
+
import type { ProjectionDefinition } from "wkt-parser";
|
|
7
|
+
import type { EpsgResolver } from "./proj.js";
|
|
8
|
+
import { epsgResolver } from "./proj.js";
|
|
8
9
|
export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
9
10
|
/**
|
|
10
11
|
* GeoTIFF input.
|
|
11
12
|
*
|
|
12
|
-
* - URL string pointing to a GeoTIFF
|
|
13
|
-
* - ArrayBuffer containing the GeoTIFF data
|
|
14
|
-
* -
|
|
15
|
-
* - An instance of GeoTIFF.js's GeoTIFF class
|
|
16
|
-
* - An instance of GeoTIFF.js's BaseClient for custom fetching
|
|
13
|
+
* - {@link URL} or `string` pointing to a GeoTIFF
|
|
14
|
+
* - {@link ArrayBuffer} containing the GeoTIFF data
|
|
15
|
+
* - An instance of the {@link GeoTIFF} class.
|
|
17
16
|
*/
|
|
18
|
-
geotiff: GeoTIFF | string |
|
|
17
|
+
geotiff: GeoTIFF | string | URL | ArrayBuffer;
|
|
19
18
|
/**
|
|
20
|
-
* A function callback for parsing
|
|
21
|
-
*
|
|
19
|
+
* A function callback for parsing numeric EPSG codes to projection
|
|
20
|
+
* information (as returned by `wkt-parser`).
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* The default implementation:
|
|
23
|
+
* - makes a request to epsg.io to resolve EPSG codes found in the GeoTIFF.
|
|
24
|
+
* - caches any previous requests
|
|
25
|
+
* - parses PROJJSON response with `wkt-parser`
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
epsgResolver?: EpsgResolver;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Decoder pool for decoding image chunks.
|
|
30
30
|
*
|
|
31
|
-
* If none is provided, a default
|
|
32
|
-
* COGLayer and GeoTIFFLayer instances.
|
|
31
|
+
* If none is provided, a default DecoderPool will be created and shared
|
|
32
|
+
* between all COGLayer and GeoTIFFLayer instances.
|
|
33
33
|
*/
|
|
34
|
-
pool?:
|
|
34
|
+
pool?: DecoderPool;
|
|
35
35
|
/**
|
|
36
36
|
* Maximum reprojection error in pixels for mesh refinement.
|
|
37
37
|
* Lower values create denser meshes with higher accuracy.
|
|
@@ -50,12 +50,9 @@ export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
|
50
50
|
debugOpacity?: number;
|
|
51
51
|
/**
|
|
52
52
|
* Called when the GeoTIFF metadata has been loaded and parsed.
|
|
53
|
-
*
|
|
54
|
-
* @param {GeoTIFF} geotiff
|
|
55
|
-
* @param {ProjectionInfo} projection
|
|
56
53
|
*/
|
|
57
54
|
onGeoTIFFLoad?: (geotiff: GeoTIFF, options: {
|
|
58
|
-
projection:
|
|
55
|
+
projection: ProjectionDefinition;
|
|
59
56
|
/**
|
|
60
57
|
* Bounds of the image in geographic coordinates (WGS84) [minLon, minLat,
|
|
61
58
|
* maxLon, maxLat]
|
|
@@ -78,7 +75,7 @@ export interface GeoTIFFLayerProps extends CompositeLayerProps {
|
|
|
78
75
|
export declare class GeoTIFFLayer extends CompositeLayer<GeoTIFFLayerProps> {
|
|
79
76
|
static layerName: string;
|
|
80
77
|
static defaultProps: {
|
|
81
|
-
|
|
78
|
+
epsgResolver: typeof epsgResolver;
|
|
82
79
|
};
|
|
83
80
|
state: {
|
|
84
81
|
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,
|
|
1
|
+
{"version":3,"file":"geotiff-layer.d.ts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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;IAwCpC,YAAY;CAsBb"}
|
package/dist/geotiff-layer.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CompositeLayer } from "@deck.gl/core";
|
|
2
2
|
import { RasterLayer } from "@developmentseed/deck.gl-raster";
|
|
3
3
|
import proj4 from "proj4";
|
|
4
|
-
import
|
|
4
|
+
import wktParser from "wkt-parser";
|
|
5
|
+
import { fetchGeoTIFF, getGeographicBounds } from "./geotiff/geotiff.js";
|
|
5
6
|
import { extractGeotiffReprojectors } from "./geotiff-reprojection.js";
|
|
6
|
-
import {
|
|
7
|
+
import { epsgResolver } from "./proj.js";
|
|
7
8
|
const defaultProps = {
|
|
8
|
-
|
|
9
|
+
epsgResolver,
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* GeoTIFFLayer renders a GeoTIFF file from an arbitrary projection.
|
|
@@ -32,30 +33,33 @@ export class GeoTIFFLayer extends CompositeLayer {
|
|
|
32
33
|
}
|
|
33
34
|
async _parseGeoTIFF() {
|
|
34
35
|
const geotiff = await fetchGeoTIFF(this.props.geotiff);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const converter = proj4(sourceProjection
|
|
36
|
+
const crs = geotiff.crs;
|
|
37
|
+
const sourceProjection = typeof crs === "number"
|
|
38
|
+
? await this.props.epsgResolver(crs)
|
|
39
|
+
: wktParser(crs);
|
|
40
|
+
// @ts-expect-error proj4 has incomplete types that don't support wkt-parser
|
|
41
|
+
// output
|
|
42
|
+
const converter = proj4(sourceProjection, "EPSG:4326");
|
|
42
43
|
if (this.props.onGeoTIFFLoad) {
|
|
43
|
-
const geographicBounds = getGeographicBounds(
|
|
44
|
+
const geographicBounds = getGeographicBounds(geotiff, converter);
|
|
44
45
|
this.props.onGeoTIFFLoad(geotiff, {
|
|
45
46
|
projection: sourceProjection,
|
|
46
47
|
geographicBounds,
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
// @ts-expect-error unused variable
|
|
51
|
+
// biome-ignore lint/correctness/noUnusedVariables: not implemented
|
|
52
|
+
const reprojectionFns = await extractGeotiffReprojectors(geotiff, sourceProjection);
|
|
53
|
+
// Our GeoTIFF implementation doesn't currently support reading the full
|
|
54
|
+
// image; it only supports reading tiles.
|
|
55
|
+
throw new Error("Loading GeoTIFF image data not yet implemented");
|
|
56
|
+
// const { texture, height, width } = await loadRgbImage(image);
|
|
57
|
+
// this.setState({
|
|
58
|
+
// reprojectionFns,
|
|
59
|
+
// imageData: texture,
|
|
60
|
+
// height,
|
|
61
|
+
// width,
|
|
62
|
+
// });
|
|
59
63
|
}
|
|
60
64
|
renderLayers() {
|
|
61
65
|
const { reprojectionFns, imageData, height, width } = this.state;
|
|
@@ -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,KAAK,MAAM,OAAO,CAAC;
|
|
1
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L,MAAM;YACN,eAAe;YACf,QAAQ;YACR,OAAO,EAAE,SAAS;YAClB,KAAK;YACL,YAAY;SACb,CAAC,CACH,CAAC;IACJ,CAAC"}
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
+
import type { Affine } from "@developmentseed/affine";
|
|
2
|
+
import type { GeoTIFF } from "@developmentseed/geotiff";
|
|
1
3
|
import type { ReprojectionFns } from "@developmentseed/raster-reproject";
|
|
2
|
-
import type { GeoTIFF, GeoTIFFImage } from "geotiff";
|
|
3
4
|
import type { PROJJSONDefinition } from "proj4/dist/lib/core";
|
|
4
5
|
import type Projection from "proj4/dist/lib/Proj";
|
|
5
|
-
|
|
6
|
-
export declare function extractGeotiffReprojectors(
|
|
7
|
-
export declare function
|
|
6
|
+
import type { ProjectionDefinition } from "wkt-parser";
|
|
7
|
+
export declare function extractGeotiffReprojectors(geotiff: GeoTIFF, sourceProjection: string | PROJJSONDefinition | ProjectionDefinition, outputCrs?: string | PROJJSONDefinition | Projection): Promise<ReprojectionFns>;
|
|
8
|
+
export declare function fromAffine(geotransform: Affine): {
|
|
8
9
|
forwardTransform: (x: number, y: number) => [number, number];
|
|
9
10
|
inverseTransform: (x: number, y: number) => [number, number];
|
|
10
11
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Extract affine geotransform from a GeoTIFF image.
|
|
13
|
-
*
|
|
14
|
-
* The first `image` must be passed in, as only the top-level IFD contains geo
|
|
15
|
-
* keys.
|
|
16
|
-
*
|
|
17
|
-
* Returns a 6-element array in Python `affine` package ordering:
|
|
18
|
-
* [a, b, c, d, e, f] where:
|
|
19
|
-
* - x_geo = a * col + b * row + c
|
|
20
|
-
* - y_geo = d * col + e * row + f
|
|
21
|
-
*
|
|
22
|
-
* This is NOT GDAL ordering, which is [c, a, b, f, d, e].
|
|
23
|
-
*/
|
|
24
|
-
export declare function extractGeotransform(image: GeoTIFFImage): [number, number, number, number, number, number];
|
|
25
12
|
//# sourceMappingURL=geotiff-reprojection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotiff-reprojection.d.ts","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geotiff-reprojection.d.ts","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,GAAG,kBAAkB,GAAG,oBAAoB,EACpE,SAAS,GAAE,MAAM,GAAG,kBAAkB,GAAG,UAAwB,GAChE,OAAO,CAAC,eAAe,CAAC,CAc1B;AAED,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG;IAChD,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,CAQA"}
|
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"geotiff-reprojection.js","sourceRoot":"","sources":["../src/geotiff-reprojection.ts"],"names":[],"mappings":"AACA,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,CAAC,YAAoB;IAI7C,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
export type { COGLayerProps } from "./cog-layer.js";
|
|
1
|
+
export type { COGLayerProps, GetTileDataOptions, MinimalDataT, } 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
|
-
export
|
|
13
|
-
export
|
|
14
|
-
metersPerUnit: (parsedCrs: import("proj4").ProjectionDefinition, crsUnit?: import("./proj.js").SupportedCrsUnit) => number;
|
|
15
|
-
};
|
|
7
|
+
export type { EpsgResolver } from "./proj.js";
|
|
8
|
+
export { epsgResolver } from "./proj.js";
|
|
16
9
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,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,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,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
|
-
export
|
|
10
|
-
import { __TEST_EXPORTS as cogTileMatrixSetTestExports } from "./cog-tile-matrix-set.js";
|
|
11
|
-
export const __TEST_EXPORTS = { ...cogTileMatrixSetTestExports };
|
|
5
|
+
export { epsgResolver } from "./proj.js";
|
|
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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,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;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
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"}
|