Add support for auto conversion to RGB

This commit is contained in:
Tim Schaub
2022-08-28 11:38:35 -05:00
parent c742fe965f
commit bd3b1bb434
6 changed files with 98 additions and 10 deletions

View File

@@ -3,7 +3,7 @@ import TileState from '../../../../../src/ol/TileState.js';
describe('ol/source/GeoTIFF', function () {
describe('constructor', function () {
it('configures readMethod_ to read rasters', function () {
it('sets convertToRGB false by default', function () {
const source = new GeoTIFFSource({
sources: [
{
@@ -11,10 +11,10 @@ describe('ol/source/GeoTIFF', function () {
},
],
});
expect(source.readMethod_).to.be('readRasters');
expect(source.convertToRGB_).to.be(false);
});
it('configures readMethod_ to read RGB', function () {
it('respects the convertToRGB option', function () {
const source = new GeoTIFFSource({
convertToRGB: true,
sources: [
@@ -23,7 +23,19 @@ describe('ol/source/GeoTIFF', function () {
},
],
});
expect(source.readMethod_).to.be('readRGB');
expect(source.convertToRGB_).to.be(true);
});
it('accepts auto convertToRGB', function () {
const source = new GeoTIFFSource({
convertToRGB: 'auto',
sources: [
{
url: 'spec/ol/source/images/0-0-0.tif',
},
],
});
expect(source.convertToRGB_).to.be('auto');
});
it('defaults to wrapX: false', function () {

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -0,0 +1,22 @@
import GeoTIFF from '../../../../src/ol/source/GeoTIFF.js';
import Map from '../../../../src/ol/Map.js';
import TileLayer from '../../../../src/ol/layer/WebGLTile.js';
const source = new GeoTIFF({
convertToRGB: 'auto',
sources: [{url: '/data/raster/masked.tif'}],
});
new Map({
layers: [
new TileLayer({
source: source,
}),
],
target: 'map',
view: source.getView(),
});
render({
message: 'automatically converts to rgb',
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,22 @@
import GeoTIFF from '../../../../src/ol/source/GeoTIFF.js';
import Map from '../../../../src/ol/Map.js';
import TileLayer from '../../../../src/ol/layer/WebGLTile.js';
const source = new GeoTIFF({
convertToRGB: false,
sources: [{url: '/data/raster/masked.tif'}],
});
new Map({
layers: [
new TileLayer({
source: source,
}),
],
target: 'map',
view: source.getView(),
});
render({
message: 'can be overridden to read raw YCbCr',
});