@gisatcz/deckgl-geolib 2.2.2 → 2.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/dist/cjs/index.js CHANGED
@@ -5255,7 +5255,7 @@ class TerrainGenerator {
5255
5255
  attributes = newAttributes;
5256
5256
  triangles = newTriangles;
5257
5257
  }
5258
- return {
5258
+ const map = {
5259
5259
  // Data return by this loader implementation
5260
5260
  loaderData: {
5261
5261
  header: {},
@@ -5268,6 +5268,14 @@ class TerrainGenerator {
5268
5268
  indices: { value: Uint32Array.from(triangles), size: 1 },
5269
5269
  attributes,
5270
5270
  };
5271
+ const gridWidth = width === 257 ? 257 : width + 1;
5272
+ const gridHeight = height === 257 ? 257 : height + 1;
5273
+ return {
5274
+ map,
5275
+ raw: terrain,
5276
+ width: gridWidth,
5277
+ height: gridHeight
5278
+ };
5271
5279
  }
5272
5280
  /**
5273
5281
  * Decodes raw raster data into a Float32Array of elevation values.
@@ -5487,7 +5495,16 @@ class BitmapGenerator {
5487
5495
  // Return raw GPU-ready ImageBitmap directly
5488
5496
  // Note: createImageBitmap(imageData) is cleaner, but using the canvas ensures broad compatibility
5489
5497
  c.putImageData(imageData, 0, 0);
5490
- return createImageBitmap(canvas);
5498
+ const map = await createImageBitmap(canvas);
5499
+ return {
5500
+ map,
5501
+ // rasters[0] is the interleaved buffer on the CogTiles path (primary use case).
5502
+ // For planar multi-band GeoTIFFs via GeoImage.getBitmap(), only the first band is exposed here.
5503
+ // Full multi-band raw picking support is tracked in https://github.com/Gisat/deck.gl-geotiff/issues/98
5504
+ raw: rasters[0],
5505
+ width,
5506
+ height
5507
+ };
5491
5508
  }
5492
5509
  static getMinMax(array, options, samplesPerPixel = 1) {
5493
5510
  let maxValue = -Infinity;
@@ -6223,6 +6240,9 @@ class CogBitmapLayer extends core.CompositeLayer {
6223
6240
  // TODO - pass signal to getTile
6224
6241
  // abort request if signal is aborted
6225
6242
  const tileData = await this.state.bitmapCogTiles.getTile(tile.index.x, tile.index.y, tile.index.z);
6243
+ if (tileData && !this.props.pickable) {
6244
+ tileData.raw = null;
6245
+ }
6226
6246
  return tileData;
6227
6247
  }
6228
6248
  renderSubLayers(props) {
@@ -6236,9 +6256,10 @@ class CogBitmapLayer extends core.CompositeLayer {
6236
6256
  }
6237
6257
  const { bbox: { west, south, east, north, }, } = props.tile;
6238
6258
  return new SubLayerClass({ ...props, tileSize: this.state.bitmapCogTiles.tileSize }, {
6239
- data: null,
6240
- image: data,
6259
+ data: [1],
6260
+ image: data.map,
6241
6261
  _instanced: false,
6262
+ pickable: props.pickable,
6242
6263
  bounds: [west, south, east, north],
6243
6264
  textureParameters: {
6244
6265
  minFilter: blurredTexture ? 'linear' : 'nearest',
@@ -6260,6 +6281,8 @@ class CogBitmapLayer extends core.CompositeLayer {
6260
6281
  }), {
6261
6282
  getTileData: this.getTiledBitmapData.bind(this),
6262
6283
  renderSubLayers: this.renderSubLayers.bind(this),
6284
+ pickable: this.props.pickable,
6285
+ onClick: this.props.onClick,
6263
6286
  updateTriggers: {
6264
6287
  getTileData: [
6265
6288
  // rasterData: urlTemplateToUpdateTrigger(rasterData),
@@ -6423,13 +6446,7 @@ class CogTerrainLayer extends core.CompositeLayer {
6423
6446
  });
6424
6447
  }
6425
6448
  async getTiledTerrainData(tile) {
6426
- // const {
6427
- // elevationData, fetch, texture, elevationDecoder, meshMaxError,
6428
- // } = this.props;
6429
6449
  const { viewport } = this.context;
6430
- // const dataUrl = getURLFromTemplate(elevationData, tile);
6431
- // const textureUrl = texture && getURLFromTemplate(texture, tile);
6432
- // const { signal } = tile;
6433
6450
  let bottomLeft = [0, 0];
6434
6451
  let topRight = [0, 0];
6435
6452
  if (viewport.isGeospatial) {
@@ -6446,6 +6463,9 @@ class CogTerrainLayer extends core.CompositeLayer {
6446
6463
  // TODO - pass signal to getTile
6447
6464
  // abort request if signal is aborted
6448
6465
  const terrain = await this.state.terrainCogTiles.getTile(tile.index.x, tile.index.y, tile.index.z, bounds, this.props.meshMaxError);
6466
+ if (terrain && !this.props.pickable) {
6467
+ terrain.raw = null;
6468
+ }
6449
6469
  return Promise.all([terrain, null]);
6450
6470
  }
6451
6471
  renderSubLayers(props) {
@@ -6456,12 +6476,13 @@ class CogTerrainLayer extends core.CompositeLayer {
6456
6476
  return null;
6457
6477
  }
6458
6478
  // const [mesh, texture] = data;
6459
- const [mesh] = data;
6479
+ const [meshResult] = data;
6460
6480
  return new SubLayerClass({ ...props, tileSize: 256 }, {
6461
6481
  data: DUMMY_DATA,
6462
- mesh,
6482
+ mesh: meshResult?.map,
6463
6483
  // texture,
6464
6484
  _instanced: false,
6485
+ pickable: props.pickable,
6465
6486
  coordinateSystem: core.COORDINATE_SYSTEM.CARTESIAN,
6466
6487
  // getPosition: (d) => [0, 0, 0],
6467
6488
  getColor: color,
@@ -6479,8 +6500,7 @@ class CogTerrainLayer extends core.CompositeLayer {
6479
6500
  .map((tile) => tile.content)
6480
6501
  .filter((x) => x && x[0])
6481
6502
  .map((arr) => {
6482
- // @ts-expect-error: Tile content structure is not fully typed in the source layer
6483
- const bounds = arr[0]?.header?.boundingBox;
6503
+ const bounds = arr[0]?.map?.header?.boundingBox;
6484
6504
  return bounds?.map((bound) => bound[2]);
6485
6505
  });
6486
6506
  if (ranges.length === 0) {
@@ -6506,6 +6526,8 @@ class CogTerrainLayer extends core.CompositeLayer {
6506
6526
  }), {
6507
6527
  getTileData: this.getTiledTerrainData.bind(this),
6508
6528
  renderSubLayers: this.renderSubLayers.bind(this),
6529
+ pickable: this.props.pickable,
6530
+ onClick: this.props.onClick,
6509
6531
  updateTriggers: {
6510
6532
  getTileData: {
6511
6533
  elevationData: urlTemplateToUpdateTrigger(elevationData),