diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 1f901ce1ee..a82e584a6b 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -1,5 +1,11 @@ ## Upgrade notes +#### Removal of ol.raster namespace + +Users compiling their code with the library and using types in the `ol.raster` namespace should note that this has now been removed. `ol.raster.Pixel` has been deleted, and the other types have been renamed as follows, and your code may need changing if you use these: +* `ol.raster.Operation` to `ol.RasterOperation` +* `ol.raster.OperationType` to `ol.RasterOperationType` + ### v3.16.0 #### Rendering change for tile sources diff --git a/externs/olx.js b/externs/olx.js index 26b8e4a7f3..34cfee3dd2 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5028,10 +5028,11 @@ olx.source.ImageVectorOptions.prototype.style; /** * @typedef {{sources: Array., - * operation: (ol.raster.Operation|undefined), + * operation: (ol.RasterOperation|undefined), * lib: (Object|undefined), * threads: (number|undefined), - * operationType: (ol.raster.OperationType|undefined)}} + * operationType: (ol.RasterOperationType|undefined)}} + * @api */ olx.source.RasterOptions; @@ -5047,7 +5048,7 @@ olx.source.RasterOptions.prototype.sources; /** * Raster operation. The operation will be called with data from input sources * and the output will be assigned to the raster source. - * @type {ol.raster.Operation|undefined} + * @type {ol.RasterOperation|undefined} * @api */ olx.source.RasterOptions.prototype.operation; @@ -5078,7 +5079,7 @@ olx.source.RasterOptions.prototype.threads; * `'pixel'` operations are assumed, and operations will be called with an * array of pixels from input sources. If set to `'image'`, operations will * be called with an array of ImageData objects from input sources. - * @type {ol.raster.OperationType|undefined} + * @type {ol.RasterOperationType|undefined} * @api */ olx.source.RasterOptions.prototype.operationType; diff --git a/src/ol/raster.jsdoc b/src/ol/raster.jsdoc deleted file mode 100644 index 8ff5d57138..0000000000 --- a/src/ol/raster.jsdoc +++ /dev/null @@ -1,3 +0,0 @@ -/** - * @namespace ol.raster - */ diff --git a/src/ol/raster/operation.js b/src/ol/raster/operation.js deleted file mode 100644 index 6133e2f73a..0000000000 --- a/src/ol/raster/operation.js +++ /dev/null @@ -1,11 +0,0 @@ -goog.provide('ol.raster.OperationType'); - - -/** - * Raster operation type. Supported values are `'pixel'` and `'image'`. - * @enum {string} - */ -ol.raster.OperationType = { - PIXEL: 'pixel', - IMAGE: 'image' -}; diff --git a/src/ol/source/rastersource.js b/src/ol/source/rastersource.js index 49bef33e23..2b1d6478ca 100644 --- a/src/ol/source/rastersource.js +++ b/src/ol/source/rastersource.js @@ -1,3 +1,4 @@ +goog.provide('ol.RasterOperationType'); goog.provide('ol.source.Raster'); goog.provide('ol.source.RasterEvent'); goog.provide('ol.source.RasterEventType'); @@ -15,7 +16,6 @@ goog.require('ol.extent'); goog.require('ol.layer.Image'); goog.require('ol.layer.Tile'); goog.require('ol.object'); -goog.require('ol.raster.OperationType'); goog.require('ol.renderer.canvas.ImageLayer'); goog.require('ol.renderer.canvas.TileLayer'); goog.require('ol.source.Image'); @@ -23,10 +23,20 @@ goog.require('ol.source.State'); goog.require('ol.source.Tile'); +/** + * Raster operation type. Supported values are `'pixel'` and `'image'`. + * @enum {string} + */ +ol.RasterOperationType = { + PIXEL: 'pixel', + IMAGE: 'image' +}; + + /** * @classdesc * A source that transforms data from any number of input sources using an array - * of {@link ol.raster.Operation} functions to transform input pixel values into + * of {@link ol.RasterOperation} functions to transform input pixel values into * output pixel values. * * @constructor @@ -45,10 +55,10 @@ ol.source.Raster = function(options) { /** * @private - * @type {ol.raster.OperationType} + * @type {ol.RasterOperationType} */ this.operationType_ = options.operationType !== undefined ? - options.operationType : ol.raster.OperationType.PIXEL; + options.operationType : ol.RasterOperationType.PIXEL; /** * @private @@ -144,7 +154,7 @@ ol.inherits(ol.source.Raster, ol.source.Image); /** * Set the operation. - * @param {ol.raster.Operation} operation New operation. + * @param {ol.RasterOperation} operation New operation. * @param {Object=} opt_lib Functions that will be available to operations run * in a worker. * @api @@ -152,7 +162,7 @@ ol.inherits(ol.source.Raster, ol.source.Image); ol.source.Raster.prototype.setOperation = function(operation, opt_lib) { this.worker_ = new ol.ext.pixelworks.Processor({ operation: operation, - imageOps: this.operationType_ === ol.raster.OperationType.IMAGE, + imageOps: this.operationType_ === ol.RasterOperationType.IMAGE, queue: 1, lib: opt_lib, threads: this.threads_ diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 26338fbd2c..71294f8d6f 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -26,7 +26,6 @@ goog.provide('ol.events.EventTargetLike'); goog.provide('ol.interaction.DragBoxEndConditionType'); goog.provide('ol.proj.ProjectionLike'); -goog.provide('ol.raster.Operation'); goog.provide('ol.style.AtlasBlock'); @@ -277,6 +276,26 @@ ol.PostRenderFunction; ol.PreRenderFunction; +/** + * A function that takes an array of input data, performs some operation, and + * returns an array of ouput data. + * For `pixel` type operations, the function will be called with an array of + * pixels, where each pixel is an array of four numbers (`[r, g, b, a]`) in the + * range of 0 - 255. It should return a single pixel array. + * For `'image'` type operations, functions will be called with an array of + * {@link ImageData https://developer.mozilla.org/en-US/docs/Web/API/ImageData} + * and should return a single {@link ImageData + * https://developer.mozilla.org/en-US/docs/Web/API/ImageData}. The operations + * are called with a second "data" argument, which can be used for storage. The + * data object is accessible from raster events, where it can be initialized in + * "beforeoperations" and accessed again in "afteroperations". + * + * @typedef {function((Array.>|Array.), Object): + * (Array.|ImageData)} + */ +ol.RasterOperation; + + /** * @typedef {function(ol.Extent, number, number) : ol.ImageBase} */ @@ -609,26 +628,6 @@ ol.interaction.SnapSegmentDataType; ol.proj.ProjectionLike; -/** - * A function that takes an array of input data, performs some operation, and - * returns an array of ouput data. - * For `pixel` type operations, the function will be called with an array of - * pixels, where each pixel is an array of four numbers (`[r, g, b, a]`) in the - * range of 0 - 255. It should return a single pixel array. - * For `'image'` type operations, functions will be called with an array of - * {@link ImageData https://developer.mozilla.org/en-US/docs/Web/API/ImageData} - * and should return a single {@link ImageData - * https://developer.mozilla.org/en-US/docs/Web/API/ImageData}. The operations - * are called with a second "data" argument, which can be used for storage. The - * data object is accessible from raster events, where it can be initialized in - * "beforeoperations" and accessed again in "afteroperations". - * - * @typedef {function((Array.>|Array.), Object): - * (Array.|ImageData)} - */ -ol.raster.Operation; - - /** * @typedef {{x: number, y: number, width: number, height: number}} */