ol 7.0.1-dev.1661713055938 → 7.0.1-dev.1661715723847

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "7.0.1-dev.1661713055938",
3
+ "version": "7.0.1-dev.1661715723847",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
@@ -141,9 +141,10 @@ export type Options = {
141
141
  /**
142
142
  * By default, bands from the sources are read as-is. When
143
143
  * reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
144
- * convert other color spaces (YCbCr, CMYK) to RGB.
144
+ * convert other color spaces (YCbCr, CMYK) to RGB. Setting the option to `'auto'` will make it so CMYK, YCbCr,
145
+ * CIELab, and ICCLab images will automatically be converted to RGB.
145
146
  */
146
- convertToRGB?: boolean | undefined;
147
+ convertToRGB?: boolean | "auto" | undefined;
147
148
  /**
148
149
  * By default, the source data is normalized to values between
149
150
  * 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
@@ -194,9 +195,10 @@ export type Options = {
194
195
  * another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha
195
196
  * band from the first source, and 1 band from the second source.
196
197
  * @property {GeoTIFFSourceOptions} [sourceOptions] Additional options to be passed to [geotiff.js](https://geotiffjs.github.io/geotiff.js/module-geotiff.html)'s `fromUrl` or `fromUrls` methods.
197
- * @property {boolean} [convertToRGB = false] By default, bands from the sources are read as-is. When
198
+ * @property {true|false|'auto'} [convertToRGB=false] By default, bands from the sources are read as-is. When
198
199
  * reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
199
- * convert other color spaces (YCbCr, CMYK) to RGB.
200
+ * convert other color spaces (YCbCr, CMYK) to RGB. Setting the option to `'auto'` will make it so CMYK, YCbCr,
201
+ * CIELab, and ICCLab images will automatically be converted to RGB.
200
202
  * @property {boolean} [normalize=true] By default, the source data is normalized to values between
201
203
  * 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
202
204
  * If instead you want to work with the raw values in a style expression, set this to `false`. Setting this option
@@ -274,9 +276,9 @@ declare class GeoTIFFSource extends DataTile {
274
276
  */
275
277
  private error_;
276
278
  /**
277
- * @type {'readRasters' | 'readRGB'}
279
+ * @type {true|false|'auto'}
278
280
  */
279
- readMethod_: 'readRasters' | 'readRGB';
281
+ convertToRGB_: true | false | 'auto';
280
282
  /**
281
283
  * @return {Error} A source loading error. When the source state is `error`, use this function
282
284
  * to get more information about the error. To debug a faulty configuration, you may want to use
@@ -1 +1 @@
1
- {"version":3,"file":"GeoTIFF.d.ts","sourceRoot":"","sources":["GeoTIFF.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAyDc,MAAM;;;;wBACN,MAAM;;;;4BACN,MAAM;;;;6BACN,MAAM;;;;6BACN,MAAM;;;;0BACN,MAAM;;;;2BACN,MAAM;;;;2BACN,MAAM;;sBAIP,OAAO,SAAS,EAAE,OAAO;2BAIzB,OAAO,SAAS,EAAE,YAAY;;;;;wBAK7B,MAAM;;;;wBACN,MAAM;;2BAOP,OAAO,SAAS,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAoO7B,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAhB/B;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EAyGjB;IA5FC;;;OAGG;IACH,oBAAkC;IAIlC;;;OAGG;IACH,uBAA2C;IAE3C;;;OAGG;IACH,uBAA2C;IAE3C;;;OAGG;IACH,qBAAyC;IAEzC;;;OAGG;IACH,2BAA+C;IAE/C;;;OAGG;IACH,yBAAqB;IAErB;;;OAGG;IACH,sBAAkB;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EtB;;;OAGG;IACH,eAAkB;IAElB;;OAEG;IACH,eAFU,IAAI,GAAC,KAAK,GAAC,MAAM,CAEuB;IAuBpD;;;;;;;;;;;OAWG;IACH,YAXY,KAAK,CAahB;IAED;;;;;;OAMG;IACH,mBAoOC;IAED;;;;;;OAMG;IACH,kBA6EC;IAED;;;;;OAKG;IACH,qBA4GC;CACF"}
package/source/GeoTIFF.js CHANGED
@@ -5,6 +5,7 @@ import DataTile from './DataTile.js';
5
5
  import TileGrid from '../tilegrid/TileGrid.js';
6
6
  import {
7
7
  Pool,
8
+ globals as geotiffGlobals,
8
9
  fromBlob as tiffFromBlob,
9
10
  fromUrl as tiffFromUrl,
10
11
  fromUrls as tiffFromUrls,
@@ -31,6 +32,31 @@ function isMask(image) {
31
32
  return (type & 4) === 4;
32
33
  }
33
34
 
35
+ /**
36
+ * @param {true|false|'auto'} preference The convertToRGB option.
37
+ * @param {GeoTIFFImage} image The image.
38
+ * @return {boolean} Use the `image.readRGB()` method.
39
+ */
40
+ function readRGB(preference, image) {
41
+ if (!preference) {
42
+ return false;
43
+ }
44
+ if (preference === true) {
45
+ return true;
46
+ }
47
+ if (image.getSamplesPerPixel() !== 3) {
48
+ return false;
49
+ }
50
+ const interpretation = image.fileDirectory.PhotometricInterpretation;
51
+ const interpretations = geotiffGlobals.photometricInterpretations;
52
+ return (
53
+ interpretation === interpretations.CMYK ||
54
+ interpretation === interpretations.YCbCr ||
55
+ interpretation === interpretations.CIELab ||
56
+ interpretation === interpretations.ICCLab
57
+ );
58
+ }
59
+
34
60
  /**
35
61
  * @typedef {Object} SourceInfo
36
62
  * @property {string} [url] URL for the source GeoTIFF.
@@ -320,9 +346,10 @@ function getMaxForDataType(array) {
320
346
  * another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha
321
347
  * band from the first source, and 1 band from the second source.
322
348
  * @property {GeoTIFFSourceOptions} [sourceOptions] Additional options to be passed to [geotiff.js](https://geotiffjs.github.io/geotiff.js/module-geotiff.html)'s `fromUrl` or `fromUrls` methods.
323
- * @property {boolean} [convertToRGB = false] By default, bands from the sources are read as-is. When
349
+ * @property {true|false|'auto'} [convertToRGB=false] By default, bands from the sources are read as-is. When
324
350
  * reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
325
- * convert other color spaces (YCbCr, CMYK) to RGB.
351
+ * convert other color spaces (YCbCr, CMYK) to RGB. Setting the option to `'auto'` will make it so CMYK, YCbCr,
352
+ * CIELab, and ICCLab images will automatically be converted to RGB.
326
353
  * @property {boolean} [normalize=true] By default, the source data is normalized to values between
327
354
  * 0 and 1 with scaling factors based on the raster statistics or `min` and `max` properties of each source.
328
355
  * If instead you want to work with the raw values in a style expression, set this to `false`. Setting this option
@@ -424,9 +451,9 @@ class GeoTIFFSource extends DataTile {
424
451
  this.error_ = null;
425
452
 
426
453
  /**
427
- * @type {'readRasters' | 'readRGB'}
454
+ * @type {true|false|'auto'}
428
455
  */
429
- this.readMethod_ = options.convertToRGB ? 'readRGB' : 'readRasters';
456
+ this.convertToRGB_ = options.convertToRGB || false;
430
457
 
431
458
  this.setKey(this.sourceInfo_.map((source) => source.url).join(','));
432
459
 
@@ -747,7 +774,7 @@ class GeoTIFFSource extends DataTile {
747
774
  }
748
775
  }
749
776
 
750
- requests[sourceIndex] = image[this.readMethod_]({
777
+ const readOptions = {
751
778
  window: pixelBounds,
752
779
  width: sourceTileSize[0],
753
780
  height: sourceTileSize[1],
@@ -755,7 +782,12 @@ class GeoTIFFSource extends DataTile {
755
782
  fillValue: fillValue,
756
783
  pool: pool,
757
784
  interleave: false,
758
- });
785
+ };
786
+ if (readRGB(this.convertToRGB_, image)) {
787
+ requests[sourceIndex] = image.readRGB(readOptions);
788
+ } else {
789
+ requests[sourceIndex] = image.readRasters(readOptions);
790
+ }
759
791
 
760
792
  // requests after `sourceCount` are for mask data (if any)
761
793
  const maskIndex = sourceCount + sourceIndex;
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '7.0.1-dev.1661713055938';
36
+ export const VERSION = '7.0.1-dev.1661715723847';