@gisatcz/deckgl-geolib 1.12.0-dev.1 → 1.12.0-dev.2

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.
@@ -1,29 +1,115 @@
1
- import { Tiff, TiffImage } from '@cogeotiff/core';
2
- import LZWDecoder from './lzw';
1
+ import { GeoTIFF, GeoTIFFImage } from 'geotiff';
3
2
  import GeoImage, { GeoImageOptions } from '../geoimage/geoimage.ts';
4
3
  export type Bounds = [minX: number, minY: number, maxX: number, maxY: number];
5
4
  declare class CogTiles {
6
- cog: Tiff;
5
+ cog: GeoTIFF;
6
+ cogZoomLookup: number[];
7
+ cogResolutionLookup: number[];
8
+ cogOrigin: number[];
7
9
  zoomRange: number[];
8
10
  tileSize: number;
9
- lowestOriginTileOffset: number[];
10
- lowestOriginTileSize: number;
11
+ bounds: Bounds;
11
12
  loaded: boolean;
12
13
  geo: GeoImage;
13
- lzw: LZWDecoder;
14
14
  options: GeoImageOptions;
15
15
  constructor(options: GeoImageOptions);
16
- initializeCog(url: string): Promise<Tiff>;
17
- getTileSize(cog: Tiff): number;
18
- getZoomRange(cog: Tiff): number[];
19
- getBoundsAsLatLon(cog: Tiff): [number, number, number, number];
20
- getOriginAsLatLon(cog: Tiff): number[];
21
- getImageTileIndex(img: TiffImage): number[];
22
- getResolutionFromZoomLevel(tileSize: number, z: number): number;
16
+ initializeCog(url: string): Promise<void>;
17
+ getZoomRange(): number[];
18
+ calculateZoomRange(img: GeoTIFFImage, imgCount: number): number[];
19
+ calculateBoundsAsLatLon(image: GeoTIFFImage): [number, number, number, number];
23
20
  getZoomLevelFromResolution(tileSize: number, resolution: number): number;
21
+ getBoundsAsLatLon(): Bounds;
24
22
  getLatLon(input: number[]): number[];
25
- getTile(x: number, y: number, z: number, bounds: Bounds, meshMaxError: number): Promise<string>;
26
- getFormat(sampleFormat: number[] | number, bitsPerSample: number[] | number): any;
27
- getNoDataValue(tags: any): number;
23
+ /**
24
+ * Builds lookup tables for zoom levels and estimated resolutions from a Cloud Optimized GeoTIFF (COG) object.
25
+ *
26
+ * It is assumed that inn web mapping, COG data is visualized in the Web Mercator coordinate system.
27
+ * At zoom level 0, the Web Mercator resolution is defined by the constant `webMercatorRes0`
28
+ * (e.g., 156543.03125 m/pixel). At each subsequent zoom level, this resolution is halved.
29
+ *
30
+ * This function calculates, for each image (overview) in the COG, its estimated resolution and
31
+ * corresponding zoom level based on the base image's resolution and width.
32
+ *
33
+ * @param {object} cog - A Cloud Optimized GeoTIFF object loaded via geotiff.js.
34
+ * @returns {Promise<[number[], number[]]>} A promise resolving to a tuple of two arrays:
35
+ * - The first array (`zoomLookup`) maps each image index to its computed zoom level.
36
+ * - The second array (`resolutionLookup`) maps each image index to its estimated resolution (m/pixel).
37
+ */
38
+ buildCogZoomResolutionLookup(cog: any): Promise<any[][]>;
39
+ /**
40
+ * Determines the appropriate image index from the Cloud Optimized GeoTIFF (COG)
41
+ * that best matches a given zoom level.
42
+ *
43
+ * This function utilizes precomputed lookup tables (`cogZoomLookup`) that map
44
+ * each image index in the COG to its corresponding zoom level. It ensures that
45
+ * the selected image index provides the closest resolution to the desired zoom level.
46
+ *
47
+ * @param {number} zoom - The target zoom level for which the image index is sought.
48
+ * @returns {number} The index of the image in the COG that best matches the specified zoom level.
49
+ */
50
+ getImageIndexForZoomLevel(zoom: any): number;
51
+ getTileFromImage(tileX: any, tileY: any, zoom: any): Promise<any[][] | import("geotiff").ReadRasterResult[]>;
52
+ getTile(x: number, y: number, z: number, bounds: Bounds, meshMaxError: number): Promise<string | {
53
+ loaderData: {
54
+ header: {};
55
+ };
56
+ header: {
57
+ vertexCount: any;
58
+ boundingBox: [[number, number, number], [number, number, number]];
59
+ };
60
+ mode: number;
61
+ indices: {
62
+ value: Uint32Array;
63
+ size: number;
64
+ };
65
+ attributes: {
66
+ POSITION: {
67
+ value: Float32Array;
68
+ size: number;
69
+ };
70
+ TEXCOORD_0: {
71
+ value: Float32Array;
72
+ size: number;
73
+ };
74
+ };
75
+ }>;
76
+ /**
77
+ * Determines the data type (e.g., "Int32", "Float64") of a GeoTIFF image
78
+ * by reading its TIFF tags.
79
+ *
80
+ * @param {GeoTIFFImage} image - A GeoTIFF.js image.
81
+ * @returns {Promise<string>} - A string representing the data type.
82
+ */
83
+ getDataTypeFromTags(image: any): string;
84
+ /**
85
+ * Extracts the noData value from a GeoTIFF.js image.
86
+ * Returns the noData value as a number if available, otherwise undefined.
87
+ *
88
+ * @param {GeoTIFFImage} image - The GeoTIFF.js image.
89
+ * @returns {number|undefined} The noData value as a number, or undefined if not available.
90
+ */
91
+ getNoDataValue(image: any): number;
92
+ /**
93
+ * Retrieves the number of channels (samples per pixel) in a GeoTIFF image.
94
+ *
95
+ * @param {GeoTIFFImage} image - A GeoTIFFImage object from which to extract the number of channels.
96
+ * @returns {number} The number of channels in the image.
97
+ */
98
+ getNumberOfChannels(image: any): any;
99
+ /**
100
+ * Retrieves the PlanarConfiguration value from a GeoTIFF image.
101
+ *
102
+ * @param {GeoTIFFImage} image - The GeoTIFF image object.
103
+ * @returns {number} The PlanarConfiguration value (1 for Chunky format, 2 for Planar format).
104
+ */
105
+ getPlanarConfiguration(image: any): any;
106
+ /**
107
+ * Creates a tile buffer of the specified size using a typed array corresponding to the provided data type.
108
+ *
109
+ * @param {string} dataType - A string specifying the data type (e.g., "Int32", "Float64", "UInt16", etc.).
110
+ * @param {number} tileSize - The width/height of the square tile.
111
+ * @returns {TypedArray} A typed array buffer of length tileSize * tileSize.
112
+ */
113
+ createTileBuffer(dataType: any, tileSize: any): Uint32Array | Float32Array | Uint8Array | Int8Array | Uint16Array | Int16Array | Int32Array | Float64Array;
28
114
  }
29
115
  export default CogTiles;
@@ -34,6 +34,7 @@ export type GeoImageOptions = {
34
34
  terrainColor?: Array<number> | chroma.Color;
35
35
  terrainSkirtHeight?: number;
36
36
  terrainMinValue?: number;
37
+ planarConfig?: number;
37
38
  };
38
39
  export declare const DefaultGeoImageOptions: GeoImageOptions;
39
40
  export default class GeoImage {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "1.12.0-dev.1",
3
+ "version": "1.12.0-dev.2",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -29,7 +29,6 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@chunkd/source-http": "^11.1.0",
32
- "@cogeotiff/core": "^9.0.3",
33
32
  "@deck.gl/core": "^9.0.33",
34
33
  "@deck.gl/extensions": "^9.0.33",
35
34
  "@deck.gl/geo-layers": "^9.0.33",
@@ -181,9 +181,9 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
181
181
  }
182
182
 
183
183
  async init() {
184
- const cog = await this.state.bitmapCogTiles.initializeCog(this.props.rasterData);
184
+ await this.state.bitmapCogTiles.initializeCog(this.props.rasterData);
185
185
 
186
- const zoomRange = this.state.bitmapCogTiles.getZoomRange(cog);
186
+ const zoomRange = this.state.bitmapCogTiles.getZoomRange();
187
187
 
188
188
  const [minZoom, maxZoom] = zoomRange;
189
189
 
@@ -307,8 +307,7 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
307
307
  clampToTerrain,
308
308
  },
309
309
  },
310
- extent: this.state.bitmapCogTiles.cog
311
- ? this.state.bitmapCogTiles.getBoundsAsLatLon(this.state.bitmapCogTiles.cog) : null,
310
+ extent: this.state.bitmapCogTiles.getBoundsAsLatLon(),
312
311
  tileSize,
313
312
  minZoom: this.state.minZoom,
314
313
  maxZoom: this.state.maxZoom,
@@ -206,10 +206,10 @@ export default class TerrainLayer<ExtraPropsT extends {} = {}> extends Composite
206
206
  }
207
207
 
208
208
  async init(terrainUrl: string) {
209
- const cog = await this.state.terrainCogTiles.initializeCog(this.props.elevationData);
209
+ await this.state.terrainCogTiles.initializeCog(this.props.elevationData);
210
210
  // this.tileSize = this.terrainCogTiles.getTileSize(cog);
211
211
 
212
- const zoomRange = this.state.terrainCogTiles.getZoomRange(cog);
212
+ const zoomRange = this.state.terrainCogTiles.getZoomRange();
213
213
 
214
214
  const [minZoom, maxZoom] = zoomRange;
215
215