Skip to content

Commit

Permalink
feat(COG): Allow tileWidth, tileHeight & resampleMethod parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin ETOURNEAU authored and Desplandis committed May 30, 2024
1 parent 809a4ad commit 24ab82f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/js/plugins/COGParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ async function readRGB(source, level, viewport) {
pool: source.pool,
width: source.tileWidth,
height: source.tileHeight,
resampleMethod: source.resampleMethod,
enableAlpha: true,
interleave: true,
});
Expand Down
9 changes: 6 additions & 3 deletions examples/js/plugins/COGSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* @property {string} url - The URL of the COG.
* @property {GeoTIFF.Pool} pool - Pool use to decode GeoTiff.
* @property {number} defaultAlpha - Alpha byte value used if no alpha is present in COG. Default value is 255.
* @property {number} tileWidth - Tile width in pixels. Default value use 'geotiff.getTileWidth()'.
* @property {number} tileHeight - Tile height in pixels. Default value use 'geotiff.getTileHeight()'.
* @property {number} resampleMethod - The desired resampling method. Default is 'nearest'.
*
* @example
* // Create the source
Expand Down Expand Up @@ -59,9 +62,9 @@ class COGSource extends itowns.Source {
this.firstImage = await geotiff.getImage();
this.origin = this.firstImage.getOrigin();
this.dataType = this.selectDataType(this.firstImage.getSampleFormat(), this.firstImage.getBitsPerSample());

this.tileWidth = this.firstImage.getTileWidth();
this.tileHeight = this.firstImage.getTileHeight();
this.tileWidth = source.tileWidth || this.firstImage.getTileWidth();
this.tileHeight = source.tileHeight || this.firstImage.getTileHeight();
this.resampleMethod = source.resampleMethod || 'nearest';

// Compute extent
const [minX, minY, maxX, maxY] = this.firstImage.getBoundingBox();
Expand Down

0 comments on commit 24ab82f

Please sign in to comment.