@developmentseed/deck.gl-geotiff 0.1.0-beta.6 → 0.2.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 +114 -9
- package/dist/cog-layer.d.ts.map +1 -1
- package/dist/cog-layer.js +126 -95
- package/dist/cog-layer.js.map +1 -1
- package/dist/cog-tile-matrix-set.d.ts +22 -1
- package/dist/cog-tile-matrix-set.d.ts.map +1 -1
- package/dist/cog-tile-matrix-set.js +25 -24
- 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 +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/mosaic-layer/mosaic-layer.d.ts +31 -0
- package/dist/mosaic-layer/mosaic-layer.d.ts.map +1 -0
- package/dist/mosaic-layer/mosaic-layer.js +59 -0
- package/dist/mosaic-layer/mosaic-layer.js.map +1 -0
- package/dist/mosaic-layer/mosaic-tileset-2d.d.ts +42 -0
- package/dist/mosaic-layer/mosaic-tileset-2d.d.ts.map +1 -0
- package/dist/mosaic-layer/mosaic-tileset-2d.js +44 -0
- package/dist/mosaic-layer/mosaic-tileset-2d.js.map +1 -0
- 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 +14 -18
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/geotiff/types.ts"],"names":[],"mappings":"AAAA,oBAAY,0BAA0B;IACpC,WAAW,IAAI;IACf,WAAW,IAAI;IACf,GAAG,IAAI;IACP,OAAO,IAAI;IACX,gBAAgB,IAAI;IACpB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,MAAM,IAAI;IACV,MAAM,IAAI;CACX;AAED,oBAAY,oBAAoB;IAC9B,MAAM,IAAI;IACV,MAAM,IAAI;CACX;AAED,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB,EAAE,0BAA0B,CAAC;IACtD,qBAAqB;IACrB,mBAAmB,EAAE,oBAAoB,CAAC;IAC1C,YAAY,EAAE,WAAW,CAAC;IAC1B,sBAAsB;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var PhotometricInterpretationT;
|
|
2
|
+
(function (PhotometricInterpretationT) {
|
|
3
|
+
PhotometricInterpretationT[PhotometricInterpretationT["WhiteIsZero"] = 0] = "WhiteIsZero";
|
|
4
|
+
PhotometricInterpretationT[PhotometricInterpretationT["BlackIsZero"] = 1] = "BlackIsZero";
|
|
5
|
+
PhotometricInterpretationT[PhotometricInterpretationT["RGB"] = 2] = "RGB";
|
|
6
|
+
PhotometricInterpretationT[PhotometricInterpretationT["Palette"] = 3] = "Palette";
|
|
7
|
+
PhotometricInterpretationT[PhotometricInterpretationT["TransparencyMask"] = 4] = "TransparencyMask";
|
|
8
|
+
PhotometricInterpretationT[PhotometricInterpretationT["CMYK"] = 5] = "CMYK";
|
|
9
|
+
PhotometricInterpretationT[PhotometricInterpretationT["YCbCr"] = 6] = "YCbCr";
|
|
10
|
+
PhotometricInterpretationT[PhotometricInterpretationT["CIELab"] = 8] = "CIELab";
|
|
11
|
+
PhotometricInterpretationT[PhotometricInterpretationT["ICCLab"] = 9] = "ICCLab";
|
|
12
|
+
})(PhotometricInterpretationT || (PhotometricInterpretationT = {}));
|
|
13
|
+
export var PlanarConfigurationT;
|
|
14
|
+
(function (PlanarConfigurationT) {
|
|
15
|
+
PlanarConfigurationT[PlanarConfigurationT["Chunky"] = 1] = "Chunky";
|
|
16
|
+
PlanarConfigurationT[PlanarConfigurationT["Planar"] = 2] = "Planar";
|
|
17
|
+
})(PlanarConfigurationT || (PlanarConfigurationT = {}));
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/geotiff/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,0BAUX;AAVD,WAAY,0BAA0B;IACpC,yFAAe,CAAA;IACf,yFAAe,CAAA;IACf,yEAAO,CAAA;IACP,iFAAW,CAAA;IACX,mGAAoB,CAAA;IACpB,2EAAQ,CAAA;IACR,6EAAS,CAAA;IACT,+EAAU,CAAA;IACV,+EAAU,CAAA;AACZ,CAAC,EAVW,0BAA0B,KAA1B,0BAA0B,QAUrC;AAED,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,mEAAU,CAAA;IACV,mEAAU,CAAA;AACZ,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B"}
|
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;AASzD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D;;;;;;;;OAQG;IACH,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,UAAU,CAAC;IAE5D;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;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;IAEtB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;QACP,UAAU,EAAE,cAAc,CAAC;QAC3B;;;WAGG;QACH,gBAAgB,EAAE;YAChB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;KACH,KACE,IAAI,CAAC;CACX;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;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":[],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AC,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
|
+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AAC,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,16 @@
|
|
|
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 type { MosaicLayerProps } from "./mosaic-layer/mosaic-layer.js";
|
|
10
|
+
export { MosaicLayer } from "./mosaic-layer/mosaic-layer.js";
|
|
11
|
+
export { type MosaicSource, MosaicTileset2D, } from "./mosaic-layer/mosaic-tileset-2d";
|
|
12
|
+
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
|
+
};
|
|
8
16
|
//# 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,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;AAIlC,eAAO,MAAM,cAAc;;CAAqC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
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 { MosaicLayer } from "./mosaic-layer/mosaic-layer.js";
|
|
8
|
+
export { MosaicTileset2D, } from "./mosaic-layer/mosaic-tileset-2d";
|
|
9
|
+
export * as proj from "./proj.js";
|
|
10
|
+
import { __TEST_EXPORTS as cogTileMatrixSetTestExports } from "./cog-tile-matrix-set.js";
|
|
11
|
+
export const __TEST_EXPORTS = { ...cogTileMatrixSetTestExports };
|
|
6
12
|
//# 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;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAEL,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,cAAc,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEzF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,2BAA2B,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CompositeLayerProps, Layer, LayersList } from "@deck.gl/core";
|
|
2
|
+
import { CompositeLayer } from "@deck.gl/core";
|
|
3
|
+
import type { TileLayerProps } from "@deck.gl/geo-layers";
|
|
4
|
+
import { TileLayer } from "@deck.gl/geo-layers";
|
|
5
|
+
import type { MosaicSource } from "./mosaic-tileset-2d";
|
|
6
|
+
export type MosaicLayerProps<MosaicT extends MosaicSource = MosaicSource, DataT = any> = CompositeLayerProps & Pick<TileLayerProps, "extent" | "minZoom" | "maxZoom" | "maxCacheByteSize" | "maxCacheSize" | "maxRequests"> & {
|
|
7
|
+
/** List of mosaic sources to render */
|
|
8
|
+
sources: MosaicT[];
|
|
9
|
+
/** Fetch data for this source. */
|
|
10
|
+
getSource?: (source: MosaicT, opts: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}) => Promise<DataT>;
|
|
13
|
+
/** Render a source */
|
|
14
|
+
renderSource: (source: MosaicT, opts: {
|
|
15
|
+
data?: DataT;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}) => Layer | LayersList | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A deck.gl layer for rendering a mosaic of raster sources.
|
|
21
|
+
*
|
|
22
|
+
* The `renderSource` prop is called whenever a source is present in the current
|
|
23
|
+
* viewport.
|
|
24
|
+
*/
|
|
25
|
+
export declare class MosaicLayer<MosaicT extends MosaicSource = MosaicSource, DataT = any> extends CompositeLayer<MosaicLayerProps<MosaicT, DataT>> {
|
|
26
|
+
static layerName: string;
|
|
27
|
+
static defaultProps: Partial<MosaicLayerProps<MosaicSource, any>>;
|
|
28
|
+
renderTileLayer(mosaicSources: MosaicT[], renderSource: MosaicLayerProps<MosaicT, DataT>["renderSource"]): TileLayer;
|
|
29
|
+
renderLayers(): Layer | null | LayersList;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=mosaic-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-layer.d.ts","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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GAC7D,SAAS;IAsDH,YAAY,IAAI,KAAK,GAAG,IAAI,GAAG,UAAU;CASnD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CompositeLayer } from "@deck.gl/core";
|
|
2
|
+
import { TileLayer } from "@deck.gl/geo-layers";
|
|
3
|
+
import { MosaicTileset2D } from "./mosaic-tileset-2d";
|
|
4
|
+
const defaultProps = {};
|
|
5
|
+
/**
|
|
6
|
+
* A deck.gl layer for rendering a mosaic of raster sources.
|
|
7
|
+
*
|
|
8
|
+
* The `renderSource` prop is called whenever a source is present in the current
|
|
9
|
+
* viewport.
|
|
10
|
+
*/
|
|
11
|
+
export class MosaicLayer extends CompositeLayer {
|
|
12
|
+
static layerName = "MosaicLayer";
|
|
13
|
+
static defaultProps = defaultProps;
|
|
14
|
+
renderTileLayer(mosaicSources, renderSource) {
|
|
15
|
+
const { id, minZoom, maxZoom, extent, maxCacheByteSize, maxCacheSize, maxRequests, } = this.props;
|
|
16
|
+
class MosaicTileset2DFactory extends MosaicTileset2D {
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
super(mosaicSources, opts);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return new TileLayer({
|
|
22
|
+
id: `mosaic-layer-${id}`,
|
|
23
|
+
TilesetClass: MosaicTileset2DFactory,
|
|
24
|
+
minZoom,
|
|
25
|
+
maxZoom,
|
|
26
|
+
extent,
|
|
27
|
+
...(maxCacheByteSize !== undefined && { maxCacheByteSize }),
|
|
28
|
+
maxCacheSize,
|
|
29
|
+
maxRequests,
|
|
30
|
+
getTileData: async (data) => {
|
|
31
|
+
// We hard-cast this because TilesetClass is not generic.
|
|
32
|
+
// TilesetClass returns MosaicT in `index`, but the known type is only
|
|
33
|
+
// `TileIndex`, which only defines x,y,z
|
|
34
|
+
const index = data.index;
|
|
35
|
+
const { signal } = data;
|
|
36
|
+
const userData = this.props.getSource &&
|
|
37
|
+
(await this.props.getSource(index, { signal }));
|
|
38
|
+
return {
|
|
39
|
+
source: index,
|
|
40
|
+
data: userData,
|
|
41
|
+
signal,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
renderSubLayers: (props) => {
|
|
45
|
+
const { data } = props;
|
|
46
|
+
const { source, signal, data: userData } = data;
|
|
47
|
+
return renderSource(source, { data: userData, signal });
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
renderLayers() {
|
|
52
|
+
const { sources, renderSource } = this.props;
|
|
53
|
+
if (!sources || sources.length === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return this.renderTileLayer(sources, renderSource);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=mosaic-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-layer.js","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-layer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkCtD,MAAM,YAAY,GAA8B,EAAE,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,OAAO,WAGX,SAAQ,cAAgD;IACxD,MAAM,CAAU,SAAS,GAAG,aAAa,CAAC;IAC1C,MAAM,CAAU,YAAY,GAAG,YAAY,CAAC;IAE5C,eAAe,CACb,aAAwB,EACxB,YAA8D;QAE9D,MAAM,EACJ,EAAE,EACF,OAAO,EACP,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,WAAW,GACZ,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,MAAM,sBAAuB,SAAQ,eAAwB;YAC3D,YAAY,IAAS;gBACnB,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YAC7B,CAAC;SACF;QAED,OAAO,IAAI,SAAS,CAIjB;YACD,E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-0,0 +1,42 @@
|
|
|
1
|
+
import type { Viewport } from "@deck.gl/core";
|
|
2
|
+
import type { _Tileset2DProps as Tileset2DProps } from "@deck.gl/geo-layers";
|
|
3
|
+
import { _Tileset2D as Tileset2D } from "@deck.gl/geo-layers";
|
|
4
|
+
/** Tile index.
|
|
5
|
+
*
|
|
6
|
+
* Note this is essentially just to type-check deck.gl, since getTileIndices
|
|
7
|
+
* must return a `TileIndex[]`.
|
|
8
|
+
*/
|
|
9
|
+
export type TileIndex = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Minimal required interface of a mosaic item.
|
|
16
|
+
*/
|
|
17
|
+
export type MosaicSource = {
|
|
18
|
+
x?: number;
|
|
19
|
+
y?: number;
|
|
20
|
+
z?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Geographic bounds (WGS84) of the source in [minX, minY, maxX, maxY] format
|
|
23
|
+
*/
|
|
24
|
+
bbox: [number, number, number, number];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A deck.gl Tileset2D for navigating an arbitrary collection of bounding boxes.
|
|
28
|
+
*
|
|
29
|
+
* This is intended to be used for a collection of image mosaics, where we want
|
|
30
|
+
* to render all images currently visible in the viewport.
|
|
31
|
+
*/
|
|
32
|
+
export declare class MosaicTileset2D<MosaicT extends MosaicSource> extends Tileset2D {
|
|
33
|
+
private sources;
|
|
34
|
+
private index;
|
|
35
|
+
constructor(sources: MosaicT[], opts: Tileset2DProps);
|
|
36
|
+
getTileIndices({ viewport, maxZoom, minZoom, }: {
|
|
37
|
+
viewport: Viewport;
|
|
38
|
+
maxZoom?: number;
|
|
39
|
+
minZoom?: number;
|
|
40
|
+
}): (TileIndex & MosaicT)[];
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=mosaic-tileset-2d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-tileset-2d.d.ts","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-tileset-2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG9D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,eAAe,CAAC,OAAO,SAAS,YAAY,CAAE,SAAQ,SAAS;IAC1E,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,KAAK,CAAW;gBAEZ,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,cAAc;IAwB3C,cAAc,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE;CAY5B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { _Tileset2D as Tileset2D } from "@deck.gl/geo-layers";
|
|
2
|
+
import Flatbush from "flatbush";
|
|
3
|
+
/**
|
|
4
|
+
* A deck.gl Tileset2D for navigating an arbitrary collection of bounding boxes.
|
|
5
|
+
*
|
|
6
|
+
* This is intended to be used for a collection of image mosaics, where we want
|
|
7
|
+
* to render all images currently visible in the viewport.
|
|
8
|
+
*/
|
|
9
|
+
export class MosaicTileset2D extends Tileset2D {
|
|
10
|
+
sources;
|
|
11
|
+
index;
|
|
12
|
+
constructor(sources, opts) {
|
|
13
|
+
super(opts);
|
|
14
|
+
// Add x,y,z to each source for TileIndex compatibility
|
|
15
|
+
// This is mostly just a hack to satisfy deck.gl typing requirements for
|
|
16
|
+
// getTileIndices
|
|
17
|
+
this.sources = sources.map((source, i) => ({
|
|
18
|
+
x: source.x === undefined ? i : source.x,
|
|
19
|
+
y: source.y === undefined ? 0 : source.y,
|
|
20
|
+
z: source.z === undefined ? 0 : source.z,
|
|
21
|
+
...source,
|
|
22
|
+
}));
|
|
23
|
+
// Build spatial index of mosaic sources
|
|
24
|
+
const index = new Flatbush(sources.length);
|
|
25
|
+
for (const source of sources) {
|
|
26
|
+
const [minX, minY, maxX, maxY] = source.bbox;
|
|
27
|
+
index.add(minX, minY, maxX, maxY);
|
|
28
|
+
}
|
|
29
|
+
index.finish();
|
|
30
|
+
this.index = index;
|
|
31
|
+
}
|
|
32
|
+
getTileIndices({ viewport, maxZoom, minZoom, }) {
|
|
33
|
+
if (viewport.zoom < (minZoom ?? -Infinity)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
if (viewport.zoom > (maxZoom ?? Infinity)) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const bounds = viewport.getBounds();
|
|
40
|
+
const indices = this.index.search(...bounds);
|
|
41
|
+
return indices.map((sourceIndex) => this.sources[sourceIndex]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=mosaic-tileset-2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mosaic-tileset-2d.js","sourceRoot":"","sources":["../../src/mosaic-layer/mosaic-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cAAc,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,OAAO,GAKR;QACC,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3C,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,IAAI,QAAQ,CAAC,EAAE,CAAC;YAC1C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAE,CAAC,CAAC;IAClE,CAAC;CACF"}
|
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 = "m" | "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,GAAG,GACH,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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