@gisatcz/deckgl-geolib 1.9.0 → 1.9.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # v1.9.2 (Wed Mar 06 2024)
2
+
3
+ #### 🐾 Patch
4
+
5
+ - Feature/fix terrain [#41](https://github.com/gisat-panther/deck.gl-geotiff/pull/41) ([@vdubr](https://github.com/vdubr))
6
+
7
+ #### Authors: 1
8
+
9
+ - Vojtěch Dubrovský ([@vdubr](https://github.com/vdubr))
10
+
11
+ ---
12
+
13
+ # v1.9.1 (Wed Jan 31 2024)
14
+
15
+ #### 🐾 Patch
16
+
17
+ - Feature/terrain options update [#40](https://github.com/gisat-panther/deck.gl-geotiff/pull/40) (mariana.kecova@gisat.cz [@MariDani](https://github.com/MariDani))
18
+
19
+ #### Authors: 2
20
+
21
+ - Mariana Kecová ([@MariDani](https://github.com/MariDani))
22
+ - Mariana Kecova (mariana.kecova@gisat.cz)
23
+
24
+ ---
25
+
1
26
  # v1.9.0 (Tue Dec 05 2023)
2
27
 
3
28
  #### 🚀 Enhancement
package/dist/cjs/index.js CHANGED
@@ -1039,9 +1039,9 @@ class TerrainEffect {
1039
1039
  }
1040
1040
 
1041
1041
  const {
1042
- viewports,
1043
- isPicking = false
1042
+ viewports
1044
1043
  } = opts;
1044
+ const isPicking = opts.pass.startsWith('picking');
1045
1045
  this.isPicking = isPicking;
1046
1046
  this.isDrapingEnabled = true;
1047
1047
  const viewport = viewports[0];
@@ -1174,7 +1174,10 @@ class TerrainEffect {
1174
1174
  devicePixelRatio: 1
1175
1175
  }
1176
1176
  });
1177
- terrainCover.isDirty = false;
1177
+
1178
+ if (!this.isPicking) {
1179
+ terrainCover.isDirty = false;
1180
+ }
1178
1181
  }
1179
1182
  } catch (err) {
1180
1183
  terrainLayer.raiseError(err, "Error rendering terrain cover ".concat(terrainCover.id));
@@ -14691,6 +14694,9 @@ const DefaultGeoImageOptions = {
14691
14694
  nullColor: [0, 0, 0, 0],
14692
14695
  unidentifiedColor: [0, 0, 0, 0],
14693
14696
  clippedColor: [0, 0, 0, 0],
14697
+ terrainColor: [133, 133, 133, 255],
14698
+ terrainSkirtHeight: 100,
14699
+ terrainMinValue: 0,
14694
14700
  };
14695
14701
  class GeoImage {
14696
14702
  constructor() {
@@ -14755,7 +14761,7 @@ class GeoImage {
14755
14761
  for (let i = 0; i < size; i += 4) {
14756
14762
  // height image calculation based on:
14757
14763
  // https://deck.gl/docs/api-reference/geo-layers/terrain-layer
14758
- const elevationValue = channel[pixel] * options.multiplier;
14764
+ const elevationValue = (options.noDataValue && channel[pixel] === options.noDataValue) ? options.terrainMinValue : channel[pixel] * options.multiplier;
14759
14765
  const colorValue = Math.floor((elevationValue + 10000) / 0.1);
14760
14766
  imageData.data[i] = Math.floor(colorValue / (256 * 256));
14761
14767
  imageData.data[i + 1] = Math.floor((colorValue / 256) % 256);
@@ -14982,6 +14988,10 @@ class GeoImage {
14982
14988
  pixelColor[3] = this.scale(dataArray[pixel], options.colorScaleValueRange[0], options.colorScaleValueRange.slice(-1)[0], 0, 255);
14983
14989
  }
14984
14990
  }
14991
+ // If pixel has null value
14992
+ }
14993
+ else if (Number.isNaN(dataArray[pixel])) {
14994
+ pixelColor = [0, 0, 0, 0];
14985
14995
  }
14986
14996
  // FIXME
14987
14997
  // eslint-disable-next-line
@@ -15378,7 +15388,7 @@ CogBitmapLayer.layerName = 'CogBitmapLayer';
15378
15388
  CogBitmapLayer.displayName = 'CogBitmapLayer';
15379
15389
 
15380
15390
  function isTileServiceUrl(url) {
15381
- if (url.includes('{x}') && url.includes('{y}') && url.includes('{z}')) {
15391
+ if (url && url.includes('{x}') && url.includes('{y}') && url.includes('{z}')) {
15382
15392
  return true;
15383
15393
  }
15384
15394
  return false;
@@ -15400,15 +15410,21 @@ class CogTerrainLayer extends core.CompositeLayer {
15400
15410
  this.urlType = 'none';
15401
15411
  this.id = '';
15402
15412
  this.id = id;
15413
+ const mergedTerrainOptions = Object.assign(Object.assign({}, DefaultGeoImageOptions), terrainOptions);
15414
+ this.terrainOpacity = mergedTerrainOptions.alpha / 100;
15415
+ this.terrainColor = chroma(mergedTerrainOptions.terrainColor.slice(0, 3)).rgb();
15416
+ this.terrainSkirtHeight = mergedTerrainOptions.terrainSkirtHeight;
15403
15417
  if (bitmapUrl) {
15404
15418
  if (isTileServiceUrl(bitmapUrl)) {
15405
15419
  this.bitmapUrl = bitmapUrl;
15406
15420
  this.urlType = 'tile';
15421
+ this.terrainColor = [0, 0, 0, 0];
15407
15422
  }
15408
15423
  else if (isCogUrl(bitmapUrl)) {
15409
15424
  this.bitmapCogTiles = new CogTiles(bitmapOptions);
15410
15425
  this.bitmapCogTiles.initializeCog(bitmapUrl);
15411
15426
  this.urlType = 'cog';
15427
+ this.terrainColor = [0, 0, 0, 0];
15412
15428
  }
15413
15429
  else {
15414
15430
  console.warn('URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format.');
@@ -15419,10 +15435,23 @@ class CogTerrainLayer extends core.CompositeLayer {
15419
15435
  this.terrainUrl = terrainUrl;
15420
15436
  }
15421
15437
  initializeState() {
15422
- this.state = {
15423
- initialized: false,
15424
- };
15425
- this.init(this.terrainUrl);
15438
+ const _super = Object.create(null, {
15439
+ initializeState: { get: () => super.initializeState }
15440
+ });
15441
+ return __awaiter(this, void 0, void 0, function* () {
15442
+ _super.initializeState.call(this);
15443
+ this.setState({
15444
+ initialized: false,
15445
+ });
15446
+ yield this.init(this.terrainUrl);
15447
+ });
15448
+ }
15449
+ shouldUpdateState() {
15450
+ var _a;
15451
+ if (((_a = this.internalState) === null || _a === void 0 ? void 0 : _a.subLayers.length) === 0) {
15452
+ return true;
15453
+ }
15454
+ return false;
15426
15455
  }
15427
15456
  init(terrainUrl) {
15428
15457
  return __awaiter(this, void 0, void 0, function* () {
@@ -15475,17 +15504,19 @@ class CogTerrainLayer extends core.CompositeLayer {
15475
15504
  },
15476
15505
  elevationData: props.data,
15477
15506
  texture: bitmapTile,
15507
+ opacity: this.terrainOpacity,
15478
15508
  bounds: [props.tile.bbox.west,
15479
15509
  props.tile.bbox.south,
15480
15510
  props.tile.bbox.east,
15481
15511
  props.tile.bbox.north,
15482
15512
  ],
15513
+ color: this.terrainColor,
15483
15514
  operation: 'terrain+draw',
15484
15515
  minZoom: this.minZoom,
15485
15516
  maxZoom: this.maxZoom,
15486
15517
  loadOptions: {
15487
15518
  terrain: {
15488
- skirtHeight: 2000,
15519
+ skirtHeight: this.terrainSkirtHeight,
15489
15520
  tesselator: 'martini',
15490
15521
  },
15491
15522
  },