@gisatcz/deckgl-geolib 1.4.2 → 1.4.3-dev.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.
@@ -46,4 +46,5 @@ export default class GeoImage {
46
46
  getColorValue(dataArray: [], options: GeoImageOptions, arrayLength: number, numOfChannels?: number): any[];
47
47
  getDefaultColor(size: any, nullColor: any): any[];
48
48
  getColorFromChromaType(colorDefinition: any): any[];
49
+ hasPixelsNoData(pixels: any, noDataValue: any): any;
49
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "1.4.2",
3
+ "version": "1.4.3-dev.0",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -67,6 +67,8 @@ class CogTerrainLayer extends CompositeLayer<any> {
67
67
  this.init(this.terrainUrl);
68
68
  }
69
69
 
70
+ // async initializeState() {}
71
+
70
72
  async init(terrainUrl: string) {
71
73
  // console.log("LAYER INITIALIZE STATE");
72
74
 
@@ -231,14 +231,18 @@ export default class GeoImage {
231
231
  imageData.data[index] = value;
232
232
  });
233
233
  }
234
+ // RGB values in one channel
234
235
  if (rasters[0].length / (width * height) === 3) {
235
236
  // console.log("geoImage: " + "RGB 1 array of length: " + rasters[0].length);
236
237
  let pixel = 0;
237
- for (let i = 0; i < size; i += 4) {
238
- imageData.data[i] = rasters[0][pixel += 1];
239
- imageData.data[i + 1] = rasters[0][pixel += 1];
240
- imageData.data[i + 2] = rasters[0][pixel += 1];
241
- imageData.data[i + 3] = optionsLocal.alpha!;
238
+ for (let idx = 0; idx < size; idx += 4) {
239
+ const rgbColor = [rasters[0][pixel], rasters[0][pixel + 1], rasters[0][pixel + 2]];
240
+ const rgbaColor = this.hasPixelsNoData(rgbColor, optionsLocal.noDataValue)
241
+ ? optionsLocal.nullColor
242
+ : [...rgbColor, optionsLocal.alpha!];
243
+ // eslint-disable-next-line max-len
244
+ [imageData.data[idx], imageData.data[idx + 1], imageData.data[idx + 2], imageData.data[idx + 3]] = rgbaColor;
245
+ pixel += 3;
242
246
  }
243
247
  }
244
248
  if (rasters[0].length / (width * height) === 4) {
@@ -387,4 +391,8 @@ export default class GeoImage {
387
391
  }
388
392
  return colorDefinition;
389
393
  }
394
+
395
+ hasPixelsNoData(pixels, noDataValue) {
396
+ return noDataValue !== undefined && pixels.every((pixel) => pixel === noDataValue);
397
+ }
390
398
  }