Allow interpolation to be configured for data tile sources

This commit is contained in:
Tim Schaub
2021-12-23 11:26:42 -07:00
parent 3edb5d6ddc
commit 8d8632bff7
14 changed files with 152 additions and 13 deletions
+9
View File
@@ -34,6 +34,8 @@ import {toPromise} from '../functions.js';
* @property {boolean} [wrapX=false] Render tiles beyond the antimeridian.
* @property {number} [transition] Transition time when fading in new tiles (in miliseconds).
* @property {number} [bandCount=4] Number of bands represented in the data.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
@@ -71,6 +73,7 @@ class DataTileSource extends TileSource {
tilePixelRatio: options.tilePixelRatio,
wrapX: options.wrapX,
transition: options.transition,
interpolate: options.interpolate,
});
/**
@@ -90,6 +93,12 @@ class DataTileSource extends TileSource {
* @type {number}
*/
this.bandCount = options.bandCount === undefined ? 4 : options.bandCount; // assume RGBA if undefined
/**
* @type {boolean}
* @private
*/
this.interpolate_ = !!options.interpolate;
}
/**
+3
View File
@@ -315,6 +315,8 @@ function getMaxForDataType(array) {
* @property {number} [transition=250] Duration of the opacity transition for rendering.
* To disable the opacity transition, pass `transition: 0`.
* @property {boolean} [wrapX=false] Render tiles beyond the tile grid extent.
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
* the linear interpolation is used to resample the data. If false, nearest neighbor is used.
*/
/**
@@ -333,6 +335,7 @@ class GeoTIFFSource extends DataTile {
projection: null,
opaque: options.opaque,
transition: options.transition,
interpolate: options.interpolate !== false,
wrapX: options.wrapX,
});
+6 -1
View File
@@ -38,6 +38,8 @@ import {scale as scaleSize, toSize} from '../size.js';
* @property {number} [transition] Transition.
* @property {string} [key] Key.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
@@ -122,7 +124,10 @@ class TileSource extends Source {
* @protected
* @type {import("../Tile.js").Options}
*/
this.tileOptions = {transition: options.transition};
this.tileOptions = {
transition: options.transition,
interpolate: options.interpolate,
};
/**
* zDirection hint, read by the renderer. Indicates which resolution should be used
+1
View File
@@ -86,6 +86,7 @@ class TileImage extends UrlTile {
urls: options.urls,
wrapX: options.wrapX,
transition: options.transition,
interpolate: options.imageSmoothing !== false,
key: options.key,
attributionsCollapsible: options.attributionsCollapsible,
zDirection: options.zDirection,
+3
View File
@@ -26,6 +26,8 @@ import {getUid} from '../util.js';
* @property {number} [transition] Transition.
* @property {string} [key] Key.
* @property {number|import("../array.js").NearestDirectionFunction} [zDirection=0] ZDirection.
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
* the nearest neighbor is used when resampling.
*/
/**
@@ -49,6 +51,7 @@ class UrlTile extends TileSource {
tilePixelRatio: options.tilePixelRatio,
wrapX: options.wrapX,
transition: options.transition,
interpolate: options.interpolate,
key: options.key,
attributionsCollapsible: options.attributionsCollapsible,
zDirection: options.zDirection,