Deprecate the imageSmoothing option for sources
This commit is contained in:
@@ -53,7 +53,9 @@ const TOS_ATTRIBUTION =
|
||||
* @property {string} [culture='en-us'] Culture code.
|
||||
* @property {string} key Bing Maps API key. Get yours at https://www.bingmapsportal.com/.
|
||||
* @property {string} imagerySet Type of imagery.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {number} [maxZoom=21] Max zoom. Default is what's advertized by the BingMaps service.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
* Higher values can increase reprojection performance, but decrease precision.
|
||||
@@ -120,10 +122,16 @@ class BingMaps extends TileImage {
|
||||
constructor(options) {
|
||||
const hidpi = options.hidpi !== undefined ? options.hidpi : false;
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: 'anonymous',
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
opaque: true,
|
||||
projection: getProjection('EPSG:3857'),
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
|
||||
@@ -93,12 +93,6 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,9 @@ import {toSize} from '../size.js';
|
||||
* @property {null|string} [crossOrigin] The value for the crossOrigin option of the request.
|
||||
* @property {import("../extent.js").Extent} [extent=[0, -height, width, 0]] The extent.
|
||||
* @property {string} [format='jpg'] Requested image format.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||
* @property {string} [quality] Requested IIIF image quality. Default is 'native'
|
||||
* for version 1, 'default' for versions 2 and 3.
|
||||
@@ -69,6 +71,12 @@ class IIIF extends TileImage {
|
||||
*/
|
||||
const options = opt_options || {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
let baseUrl = options.url || '';
|
||||
baseUrl =
|
||||
baseUrl +
|
||||
@@ -333,7 +341,7 @@ class IIIF extends TileImage {
|
||||
attributionsCollapsible: options.attributionsCollapsible,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
state: options.state,
|
||||
|
||||
@@ -6,7 +6,6 @@ import ImageState from '../ImageState.js';
|
||||
import ReprojImage from '../reproj/Image.js';
|
||||
import Source from './Source.js';
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from './common.js';
|
||||
import {abstract} from '../util.js';
|
||||
import {equals} from '../extent.js';
|
||||
import {equivalent} from '../proj.js';
|
||||
@@ -76,7 +75,9 @@ export class ImageSourceEvent extends Event {
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||
* @property {Array<number>} [resolutions] Resolutions.
|
||||
* @property {import("./State.js").default} [state] State.
|
||||
@@ -96,10 +97,17 @@ class ImageSource extends Source {
|
||||
* @param {Options} options Single image source options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
projection: options.projection,
|
||||
state: options.state,
|
||||
interpolate: interpolate,
|
||||
});
|
||||
|
||||
/***
|
||||
@@ -135,13 +143,6 @@ class ImageSource extends Source {
|
||||
* @type {number}
|
||||
*/
|
||||
this.reprojectedRevision_ = 0;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {object|undefined}
|
||||
*/
|
||||
this.contextOptions_ =
|
||||
options.imageSmoothing === false ? IMAGE_SMOOTHING_DISABLED : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,13 +152,6 @@ class ImageSource extends Source {
|
||||
return this.resolutions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object|undefined} Context options.
|
||||
*/
|
||||
getContextOptions() {
|
||||
return this.contextOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @param {number} resolution Resolution.
|
||||
@@ -218,7 +212,7 @@ class ImageSource extends Source {
|
||||
sourceProjection
|
||||
);
|
||||
}.bind(this),
|
||||
this.contextOptions_
|
||||
this.getInterpolate()
|
||||
);
|
||||
this.reprojectedRevision_ = this.getRevision();
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ import {containsExtent, getHeight, getWidth} from '../extent.js';
|
||||
* the remote server.
|
||||
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given
|
||||
* a URL.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service
|
||||
* defaults will be used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is
|
||||
* `IMAGE` by default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`, and `IMAGESR`
|
||||
@@ -57,9 +59,15 @@ class ImageArcGISRest extends ImageSource {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
});
|
||||
|
||||
@@ -36,7 +36,9 @@ import {
|
||||
* the value returned by the function is later changed then
|
||||
* `changed` should be called on the source for the source to
|
||||
* invalidate the current cached image. See: {@link module:ol/Observable~Observable#changed}
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
|
||||
* width and height of the map viewport, and so on. Must be `1` or higher.
|
||||
@@ -57,9 +59,15 @@ class ImageCanvasSource extends ImageSource {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
state: options.state,
|
||||
|
||||
@@ -32,7 +32,9 @@ import {
|
||||
* @property {Array<number>} [resolutions] Resolutions.
|
||||
* If specified, requests will be made for these resolutions only.
|
||||
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {Object} [params] Additional parameters.
|
||||
*/
|
||||
|
||||
@@ -48,8 +50,14 @@ class ImageMapGuide extends ImageSource {
|
||||
* @param {Options} options ImageMapGuide options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import EventType from '../events/EventType.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from './Image.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import ImageWrapper from '../Image.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from '../renderer/canvas/common.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {getHeight, getWidth, intersects} from '../extent.js';
|
||||
@@ -20,7 +21,9 @@ import {get as getProjection} from '../proj.js';
|
||||
* @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
|
||||
* This is the [left, bottom, right, top] map coordinates of your image.
|
||||
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
|
||||
* only needs to be set if auto-detection fails for some reason.
|
||||
@@ -45,9 +48,15 @@ class Static extends ImageSource {
|
||||
? options.imageLoadFunction
|
||||
: defaultImageLoadFunction;
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: getProjection(options.projection),
|
||||
});
|
||||
|
||||
@@ -148,7 +157,9 @@ class Static extends ImageSource {
|
||||
}
|
||||
if (targetWidth !== imageWidth || targetHeight !== imageHeight) {
|
||||
const context = createCanvasContext2D(targetWidth, targetHeight);
|
||||
assign(context, this.getContextOptions());
|
||||
if (!this.getInterpolate()) {
|
||||
assign(context, IMAGE_SMOOTHING_DISABLED);
|
||||
}
|
||||
const canvas = context.canvas;
|
||||
context.drawImage(
|
||||
image,
|
||||
|
||||
@@ -46,7 +46,9 @@ const GETFEATUREINFO_IMAGE_SIZE = [101, 101];
|
||||
* @property {import("./WMSServerType.js").default|string} [serverType] The type of
|
||||
* the remote WMS server: `mapserver`, `geoserver` or `qgis`. Only needed if `hidpi` is `true`.
|
||||
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {Object<string,*>} params WMS request parameters.
|
||||
* At least a `LAYERS` param is required. `STYLES` is
|
||||
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
|
||||
@@ -74,9 +76,15 @@ class ImageWMS extends ImageSource {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
});
|
||||
|
||||
@@ -20,7 +20,9 @@ import {getTileSetInfo} from './ogcTileUtil.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
* Higher values can increase reprojection performance, but decrease precision.
|
||||
* @property {import("../Tile.js").LoadFunction} [tileLoadFunction] Optional function to load a tile given a URL. The default is
|
||||
@@ -45,11 +47,17 @@ class OGCMapTile extends TileImage {
|
||||
* @param {Options} options OGC map tile options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
state: SourceState.LOADING,
|
||||
|
||||
@@ -23,7 +23,9 @@ export const ATTRIBUTION =
|
||||
* @property {null|string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {number} [maxZoom=19] Max zoom.
|
||||
* @property {boolean} [opaque=true] Whether the layer is opaque.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -56,6 +58,12 @@ class OSM extends XYZ {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options || {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
let attributions;
|
||||
if (options.attributions !== undefined) {
|
||||
attributions = options.attributions;
|
||||
@@ -76,7 +84,7 @@ class OSM extends XYZ {
|
||||
attributionsCollapsible: false,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
|
||||
opaque: options.opaque !== undefined ? options.opaque : true,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
|
||||
@@ -31,6 +31,8 @@ import {get as getProjection} from '../proj.js';
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {import("./State.js").default} [state='ready'] State.
|
||||
* @property {boolean} [wrapX=false] WrapX.
|
||||
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
|
||||
* the nearest neighbor is used when resampling.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -91,6 +93,12 @@ class Source extends BaseObject {
|
||||
*/
|
||||
this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.interpolate_ = !!options.interpolate;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {function(import("../View.js").ViewOptions):void}
|
||||
@@ -172,10 +180,10 @@ class Source extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object|undefined} Context options.
|
||||
* @return {boolean} Use linear interpolation when resampling.
|
||||
*/
|
||||
getContextOptions() {
|
||||
return undefined;
|
||||
getInterpolate() {
|
||||
return this.interpolate_;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,9 @@ const ProviderConfig = {
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {string} layer Layer name.
|
||||
* @property {number} [minZoom] Minimum zoom.
|
||||
* @property {number} [maxZoom] Maximum zoom.
|
||||
@@ -119,6 +121,12 @@ class Stamen extends XYZ {
|
||||
* @param {Options} options Stamen options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
const i = options.layer.indexOf('-');
|
||||
const provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||
const providerConfig = ProviderConfig[provider];
|
||||
@@ -137,7 +145,7 @@ class Stamen extends XYZ {
|
||||
attributions: ATTRIBUTIONS,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: 'anonymous',
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
maxZoom:
|
||||
options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
|
||||
minZoom:
|
||||
|
||||
@@ -61,6 +61,7 @@ class TileSource extends Source {
|
||||
projection: options.projection,
|
||||
state: options.state,
|
||||
wrapX: options.wrapX,
|
||||
interpolate: options.interpolate,
|
||||
});
|
||||
|
||||
/***
|
||||
|
||||
@@ -17,7 +17,9 @@ import {hash as tileCoordHash} from '../tilecoord.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {Object<string,*>} [params] ArcGIS Rest parameters. This field is optional. Service defaults will be
|
||||
* used for any fields not specified. `FORMAT` is `PNG32` by default. `F` is `IMAGE` by
|
||||
* default. `TRANSPARENT` is `true` by default. `BBOX`, `SIZE`, `BBOXSR`,
|
||||
@@ -72,11 +74,17 @@ class TileArcGISRest extends TileImage {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileGrid: options.tileGrid,
|
||||
|
||||
@@ -8,7 +8,6 @@ import TileCache from '../TileCache.js';
|
||||
import TileState from '../TileState.js';
|
||||
import UrlTile from './UrlTile.js';
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from './common.js';
|
||||
import {equivalent, get as getProjection} from '../proj.js';
|
||||
import {getKey, getKeyZXY} from '../tilecoord.js';
|
||||
import {getForProjection as getTileGridForProjection} from '../tilegrid.js';
|
||||
@@ -22,7 +21,9 @@ import {getUid} from '../util.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -70,6 +71,12 @@ class TileImage extends UrlTile {
|
||||
* @param {!Options} options Image tile options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
@@ -86,7 +93,7 @@ class TileImage extends UrlTile {
|
||||
urls: options.urls,
|
||||
wrapX: options.wrapX,
|
||||
transition: options.transition,
|
||||
interpolate: options.imageSmoothing !== false,
|
||||
interpolate: interpolate,
|
||||
key: options.key,
|
||||
attributionsCollapsible: options.attributionsCollapsible,
|
||||
zDirection: options.zDirection,
|
||||
@@ -124,13 +131,6 @@ class TileImage extends UrlTile {
|
||||
*/
|
||||
this.reprojectionErrorThreshold_ = options.reprojectionErrorThreshold;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {object|undefined}
|
||||
*/
|
||||
this.contextOptions_ =
|
||||
options.imageSmoothing === false ? IMAGE_SMOOTHING_DISABLED : undefined;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
@@ -177,13 +177,6 @@ class TileImage extends UrlTile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object|undefined} Context options.
|
||||
*/
|
||||
getContextOptions() {
|
||||
return this.contextOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../proj/Projection.js").default} projection Projection.
|
||||
* @return {number} Gutter.
|
||||
@@ -213,10 +206,11 @@ class TileImage extends UrlTile {
|
||||
* @return {string} The key for all tiles.
|
||||
*/
|
||||
getKey() {
|
||||
return (
|
||||
super.getKey() +
|
||||
(this.contextOptions_ ? '\n' + JSON.stringify(this.contextOptions_) : '')
|
||||
);
|
||||
let key = super.getKey();
|
||||
if (!this.getInterpolate()) {
|
||||
key += ':disable-interpolation';
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +360,7 @@ class TileImage extends UrlTile {
|
||||
}.bind(this),
|
||||
this.reprojectionErrorThreshold_,
|
||||
this.renderReprojectionEdges_,
|
||||
this.contextOptions_
|
||||
this.getInterpolate()
|
||||
);
|
||||
newTile.key = key;
|
||||
|
||||
|
||||
@@ -40,7 +40,9 @@ import {jsonp as requestJSONP} from '../net.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {boolean} [jsonp=false] Use JSONP with callback to load the TileJSON.
|
||||
* Useful when the server does not support CORS..
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -74,11 +76,17 @@ class TileJSON extends TileImage {
|
||||
* @param {Options} options TileJSON options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: getProjection('EPSG:3857'),
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
state: SourceState.LOADING,
|
||||
|
||||
@@ -25,7 +25,9 @@ import {hash as tileCoordHash} from '../tilecoord.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {Object<string,*>} params WMS request parameters.
|
||||
* At least a `LAYERS` param is required. `STYLES` is
|
||||
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
|
||||
@@ -86,6 +88,12 @@ class TileWMS extends TileImage {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options ? opt_options : /** @type {Options} */ ({});
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
const params = options.params || {};
|
||||
|
||||
const transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
|
||||
@@ -95,7 +103,7 @@ class TileWMS extends TileImage {
|
||||
attributionsCollapsible: options.attributionsCollapsible,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
opaque: !transparent,
|
||||
projection: options.projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
|
||||
@@ -20,7 +20,9 @@ import {find, findIndex, includes} from '../array.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../tilegrid/WMTS.js").default} tileGrid Tile grid.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -69,6 +71,12 @@ class WMTS extends TileImage {
|
||||
* @param {Options} options WMTS options.
|
||||
*/
|
||||
constructor(options) {
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
// TODO: add support for TileMatrixLimits
|
||||
|
||||
const requestEncoding =
|
||||
@@ -92,7 +100,7 @@ class WMTS extends TileImage {
|
||||
attributionsCollapsible: options.attributionsCollapsible,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileClass: options.tileClass,
|
||||
|
||||
@@ -13,7 +13,9 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js';
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection.
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -72,6 +74,13 @@ class XYZ extends TileImage {
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
const options = opt_options || {};
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
const projection =
|
||||
options.projection !== undefined ? options.projection : 'EPSG:3857';
|
||||
|
||||
@@ -90,7 +99,7 @@ class XYZ extends TileImage {
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
opaque: options.opaque,
|
||||
projection: projection,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
|
||||
@@ -87,7 +87,9 @@ export class CustomTile extends ImageTile {
|
||||
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
|
||||
* you must provide a `crossOrigin` value you want to access pixel data with the Canvas renderer.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||
* @property {number} [tilePixelRatio] The pixel ratio used by the tile service. For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px by 512px images (for retina/hidpi devices) then `tilePixelRatio` should be set to `2`
|
||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||
@@ -131,6 +133,12 @@ class Zoomify extends TileImage {
|
||||
constructor(opt_options) {
|
||||
const options = opt_options;
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
const size = options.size;
|
||||
const tierSizeCalculation =
|
||||
options.tierSizeCalculation !== undefined
|
||||
@@ -260,7 +268,7 @@ class Zoomify extends TileImage {
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: options.projection,
|
||||
tilePixelRatio: tilePixelRatio,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
|
||||
@@ -7,12 +7,3 @@
|
||||
* @type {string}
|
||||
*/
|
||||
export const DEFAULT_WMS_VERSION = '1.3.0';
|
||||
|
||||
/**
|
||||
* Context options to disable image smoothing.
|
||||
* @type {Object}
|
||||
*/
|
||||
export const IMAGE_SMOOTHING_DISABLED = {
|
||||
imageSmoothingEnabled: false,
|
||||
msImageSmoothingEnabled: false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user