Don't store private functions and variables into RasterSource
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import _ol_View_ from '../src/ol/View.js';
|
import _ol_View_ from '../src/ol/View.js';
|
||||||
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
||||||
import _ol_source_Raster_ from '../src/ol/source/Raster.js';
|
import RasterSource from '../src/ol/source/Raster.js';
|
||||||
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
|
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ function xyz2rgb(x) {
|
|||||||
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
||||||
}
|
}
|
||||||
|
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [new _ol_source_Stamen_({
|
sources: [new _ol_source_Stamen_({
|
||||||
layer: 'watercolor',
|
layer: 'watercolor',
|
||||||
transition: 0
|
transition: 0
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import _ol_View_ from '../src/ol/View.js';
|
|||||||
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
||||||
import _ol_source_Raster_ from '../src/ol/source/Raster.js';
|
import RasterSource from '../src/ol/source/Raster.js';
|
||||||
|
|
||||||
var minVgi = 0;
|
var minVgi = 0;
|
||||||
var maxVgi = 0.25;
|
var maxVgi = 0.25;
|
||||||
@@ -59,7 +59,7 @@ var bing = new _ol_source_BingMaps_({
|
|||||||
* Create a raster source where pixels with VGI values above a threshold will
|
* Create a raster source where pixels with VGI values above a threshold will
|
||||||
* be colored green.
|
* be colored green.
|
||||||
*/
|
*/
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [bing],
|
sources: [bing],
|
||||||
/**
|
/**
|
||||||
* Run calculations on pixel data.
|
* Run calculations on pixel data.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
|||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
||||||
import _ol_source_Raster_ from '../src/ol/source/Raster.js';
|
import RasterSource from '../src/ol/source/Raster.js';
|
||||||
|
|
||||||
function growRegion(inputs, data) {
|
function growRegion(inputs, data) {
|
||||||
var image = inputs[0];
|
var image = inputs[0];
|
||||||
@@ -78,7 +78,7 @@ var imagery = new TileLayer({
|
|||||||
source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'})
|
source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'})
|
||||||
});
|
});
|
||||||
|
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [imagery.getSource()],
|
sources: [imagery.getSource()],
|
||||||
operationType: 'image',
|
operationType: 'image',
|
||||||
operation: growRegion,
|
operation: growRegion,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import _ol_View_ from '../src/ol/View.js';
|
|||||||
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
import _ol_source_Raster_ from '../src/ol/source/Raster.js';
|
import RasterSource from '../src/ol/source/Raster.js';
|
||||||
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
|
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
function flood(pixels, data) {
|
function flood(pixels, data) {
|
||||||
@@ -30,7 +30,7 @@ var elevation = new _ol_source_XYZ_({
|
|||||||
transition: 0
|
transition: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [elevation],
|
sources: [elevation],
|
||||||
operation: flood
|
operation: flood
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import _ol_View_ from '../src/ol/View.js';
|
|||||||
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||||
import _ol_source_Raster_ from '../src/ol/source/Raster.js';
|
import RasterSource from '../src/ol/source/Raster.js';
|
||||||
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
|
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ var elevation = new _ol_source_XYZ_({
|
|||||||
transition: 0
|
transition: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [elevation],
|
sources: [elevation],
|
||||||
operationType: 'image',
|
operationType: 'image',
|
||||||
operation: shade
|
operation: shade
|
||||||
|
|||||||
@@ -21,6 +21,27 @@ import SourceState from '../source/State.js';
|
|||||||
import _ol_source_Tile_ from '../source/Tile.js';
|
import _ol_source_Tile_ from '../source/Tile.js';
|
||||||
import _ol_transform_ from '../transform.js';
|
import _ol_transform_ from '../transform.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
var RasterEventType = {
|
||||||
|
/**
|
||||||
|
* Triggered before operations are run.
|
||||||
|
* @event ol.source.Raster.Event#beforeoperations
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
BEFOREOPERATIONS: 'beforeoperations',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered after operations are run.
|
||||||
|
* @event ol.source.Raster.Event#afteroperations
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
AFTEROPERATIONS: 'afteroperations'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* A source that transforms data from any number of input sources using an
|
* A source that transforms data from any number of input sources using an
|
||||||
@@ -33,7 +54,7 @@ import _ol_transform_ from '../transform.js';
|
|||||||
* @param {olx.source.RasterOptions} options Options.
|
* @param {olx.source.RasterOptions} options Options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_source_Raster_ = function(options) {
|
var RasterSource = function(options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -58,7 +79,7 @@ var _ol_source_Raster_ = function(options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {Array.<ol.renderer.canvas.Layer>}
|
* @type {Array.<ol.renderer.canvas.Layer>}
|
||||||
*/
|
*/
|
||||||
this.renderers_ = _ol_source_Raster_.createRenderers_(options.sources);
|
this.renderers_ = createRenderers(options.sources);
|
||||||
|
|
||||||
for (var r = 0, rr = this.renderers_.length; r < rr; ++r) {
|
for (var r = 0, rr = this.renderers_.length; r < rr; ++r) {
|
||||||
_ol_events_.listen(this.renderers_[r], EventType.CHANGE,
|
_ol_events_.listen(this.renderers_[r], EventType.CHANGE,
|
||||||
@@ -75,7 +96,7 @@ var _ol_source_Raster_ = function(options) {
|
|||||||
},
|
},
|
||||||
this.changed.bind(this));
|
this.changed.bind(this));
|
||||||
|
|
||||||
var layerStatesArray = _ol_source_Raster_.getLayerStatesArray_(this.renderers_);
|
var layerStatesArray = getLayerStatesArray(this.renderers_);
|
||||||
var layerStates = {};
|
var layerStates = {};
|
||||||
for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
|
layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
|
||||||
@@ -136,7 +157,7 @@ var _ol_source_Raster_ = function(options) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_source_Raster_, _ol_source_Image_);
|
inherits(RasterSource, _ol_source_Image_);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,7 +167,7 @@ inherits(_ol_source_Raster_, _ol_source_Image_);
|
|||||||
* in a worker.
|
* in a worker.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.setOperation = function(operation, opt_lib) {
|
RasterSource.prototype.setOperation = function(operation, opt_lib) {
|
||||||
this.worker_ = new Processor({
|
this.worker_ = new Processor({
|
||||||
operation: operation,
|
operation: operation,
|
||||||
imageOps: this.operationType_ === RasterOperationType.IMAGE,
|
imageOps: this.operationType_ === RasterOperationType.IMAGE,
|
||||||
@@ -166,7 +187,7 @@ _ol_source_Raster_.prototype.setOperation = function(operation, opt_lib) {
|
|||||||
* @return {olx.FrameState} The updated frame state.
|
* @return {olx.FrameState} The updated frame state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.updateFrameState_ = function(extent, resolution, projection) {
|
RasterSource.prototype.updateFrameState_ = function(extent, resolution, projection) {
|
||||||
|
|
||||||
var frameState = /** @type {olx.FrameState} */ (
|
var frameState = /** @type {olx.FrameState} */ (
|
||||||
_ol_obj_.assign({}, this.frameState_));
|
_ol_obj_.assign({}, this.frameState_));
|
||||||
@@ -196,7 +217,7 @@ _ol_source_Raster_.prototype.updateFrameState_ = function(extent, resolution, pr
|
|||||||
* @return {boolean} All sources are ready.
|
* @return {boolean} All sources are ready.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.allSourcesReady_ = function() {
|
RasterSource.prototype.allSourcesReady_ = function() {
|
||||||
var ready = true;
|
var ready = true;
|
||||||
var source;
|
var source;
|
||||||
for (var i = 0, ii = this.renderers_.length; i < ii; ++i) {
|
for (var i = 0, ii = this.renderers_.length; i < ii; ++i) {
|
||||||
@@ -213,7 +234,7 @@ _ol_source_Raster_.prototype.allSourcesReady_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
|
RasterSource.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
|
||||||
if (!this.allSourcesReady_()) {
|
if (!this.allSourcesReady_()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -248,12 +269,12 @@ _ol_source_Raster_.prototype.getImage = function(extent, resolution, pixelRatio,
|
|||||||
* Start processing source data.
|
* Start processing source data.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.processSources_ = function() {
|
RasterSource.prototype.processSources_ = function() {
|
||||||
var frameState = this.requestedFrameState_;
|
var frameState = this.requestedFrameState_;
|
||||||
var len = this.renderers_.length;
|
var len = this.renderers_.length;
|
||||||
var imageDatas = new Array(len);
|
var imageDatas = new Array(len);
|
||||||
for (var i = 0; i < len; ++i) {
|
for (var i = 0; i < len; ++i) {
|
||||||
var imageData = _ol_source_Raster_.getImageData_(
|
var imageData = getImageData(
|
||||||
this.renderers_[i], frameState, frameState.layerStatesArray[i]);
|
this.renderers_[i], frameState, frameState.layerStatesArray[i]);
|
||||||
if (imageData) {
|
if (imageData) {
|
||||||
imageDatas[i] = imageData;
|
imageDatas[i] = imageData;
|
||||||
@@ -263,10 +284,8 @@ _ol_source_Raster_.prototype.processSources_ = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var data = {};
|
var data = {};
|
||||||
this.dispatchEvent(new _ol_source_Raster_.Event(
|
this.dispatchEvent(new RasterSource.Event(RasterEventType.BEFOREOPERATIONS, frameState, data));
|
||||||
_ol_source_Raster_.EventType_.BEFOREOPERATIONS, frameState, data));
|
this.worker_.process(imageDatas, data, this.onWorkerComplete_.bind(this, frameState));
|
||||||
this.worker_.process(imageDatas, data,
|
|
||||||
this.onWorkerComplete_.bind(this, frameState));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -278,7 +297,7 @@ _ol_source_Raster_.prototype.processSources_ = function() {
|
|||||||
* @param {Object} data The user data.
|
* @param {Object} data The user data.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
|
RasterSource.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
|
||||||
if (err || !output) {
|
if (err || !output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -305,8 +324,7 @@ _ol_source_Raster_.prototype.onWorkerComplete_ = function(frameState, err, outpu
|
|||||||
this.changed();
|
this.changed();
|
||||||
this.renderedRevision_ = this.getRevision();
|
this.renderedRevision_ = this.getRevision();
|
||||||
|
|
||||||
this.dispatchEvent(new _ol_source_Raster_.Event(
|
this.dispatchEvent(new RasterSource.Event(RasterEventType.AFTEROPERATIONS, frameState, data));
|
||||||
_ol_source_Raster_.EventType_.AFTEROPERATIONS, frameState, data));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -316,27 +334,26 @@ _ol_source_Raster_.prototype.onWorkerComplete_ = function(frameState, err, outpu
|
|||||||
* @param {olx.FrameState} frameState The frame state.
|
* @param {olx.FrameState} frameState The frame state.
|
||||||
* @param {ol.LayerState} layerState The layer state.
|
* @param {ol.LayerState} layerState The layer state.
|
||||||
* @return {ImageData} The image data.
|
* @return {ImageData} The image data.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.getImageData_ = function(renderer, frameState, layerState) {
|
function getImageData(renderer, frameState, layerState) {
|
||||||
if (!renderer.prepareFrame(frameState, layerState)) {
|
if (!renderer.prepareFrame(frameState, layerState)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var width = frameState.size[0];
|
var width = frameState.size[0];
|
||||||
var height = frameState.size[1];
|
var height = frameState.size[1];
|
||||||
if (!_ol_source_Raster_.context_) {
|
if (!RasterSource.context_) {
|
||||||
_ol_source_Raster_.context_ = createCanvasContext2D(width, height);
|
RasterSource.context_ = createCanvasContext2D(width, height);
|
||||||
} else {
|
} else {
|
||||||
var canvas = _ol_source_Raster_.context_.canvas;
|
var canvas = RasterSource.context_.canvas;
|
||||||
if (canvas.width !== width || canvas.height !== height) {
|
if (canvas.width !== width || canvas.height !== height) {
|
||||||
_ol_source_Raster_.context_ = createCanvasContext2D(width, height);
|
RasterSource.context_ = createCanvasContext2D(width, height);
|
||||||
} else {
|
} else {
|
||||||
_ol_source_Raster_.context_.clearRect(0, 0, width, height);
|
RasterSource.context_.clearRect(0, 0, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
renderer.composeFrame(frameState, layerState, _ol_source_Raster_.context_);
|
renderer.composeFrame(frameState, layerState, RasterSource.context_);
|
||||||
return _ol_source_Raster_.context_.getImageData(0, 0, width, height);
|
return RasterSource.context_.getImageData(0, 0, width, height);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -344,77 +361,72 @@ _ol_source_Raster_.getImageData_ = function(renderer, frameState, layerState) {
|
|||||||
* @type {CanvasRenderingContext2D}
|
* @type {CanvasRenderingContext2D}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.context_ = null;
|
RasterSource.context_ = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of layer states from a list of renderers.
|
* Get a list of layer states from a list of renderers.
|
||||||
* @param {Array.<ol.renderer.canvas.Layer>} renderers Layer renderers.
|
* @param {Array.<ol.renderer.canvas.Layer>} renderers Layer renderers.
|
||||||
* @return {Array.<ol.LayerState>} The layer states.
|
* @return {Array.<ol.LayerState>} The layer states.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.getLayerStatesArray_ = function(renderers) {
|
function getLayerStatesArray(renderers) {
|
||||||
return renderers.map(function(renderer) {
|
return renderers.map(function(renderer) {
|
||||||
return renderer.getLayer().getLayerState();
|
return renderer.getLayer().getLayerState();
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create renderers for all sources.
|
* Create renderers for all sources.
|
||||||
* @param {Array.<ol.source.Source>} sources The sources.
|
* @param {Array.<ol.source.Source>} sources The sources.
|
||||||
* @return {Array.<ol.renderer.canvas.Layer>} Array of layer renderers.
|
* @return {Array.<ol.renderer.canvas.Layer>} Array of layer renderers.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.createRenderers_ = function(sources) {
|
function createRenderers(sources) {
|
||||||
var len = sources.length;
|
var len = sources.length;
|
||||||
var renderers = new Array(len);
|
var renderers = new Array(len);
|
||||||
for (var i = 0; i < len; ++i) {
|
for (var i = 0; i < len; ++i) {
|
||||||
renderers[i] = _ol_source_Raster_.createRenderer_(sources[i]);
|
renderers[i] = createRenderer(sources[i]);
|
||||||
}
|
}
|
||||||
return renderers;
|
return renderers;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a renderer for the provided source.
|
* Create a renderer for the provided source.
|
||||||
* @param {ol.source.Source} source The source.
|
* @param {ol.source.Source} source The source.
|
||||||
* @return {ol.renderer.canvas.Layer} The renderer.
|
* @return {ol.renderer.canvas.Layer} The renderer.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.createRenderer_ = function(source) {
|
function createRenderer(source) {
|
||||||
var renderer = null;
|
var renderer = null;
|
||||||
if (source instanceof _ol_source_Tile_) {
|
if (source instanceof _ol_source_Tile_) {
|
||||||
renderer = _ol_source_Raster_.createTileRenderer_(source);
|
renderer = createTileRenderer(source);
|
||||||
} else if (source instanceof _ol_source_Image_) {
|
} else if (source instanceof _ol_source_Image_) {
|
||||||
renderer = _ol_source_Raster_.createImageRenderer_(source);
|
renderer = createImageRenderer(source);
|
||||||
}
|
}
|
||||||
return renderer;
|
return renderer;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an image renderer for the provided source.
|
* Create an image renderer for the provided source.
|
||||||
* @param {ol.source.Image} source The source.
|
* @param {ol.source.Image} source The source.
|
||||||
* @return {ol.renderer.canvas.Layer} The renderer.
|
* @return {ol.renderer.canvas.Layer} The renderer.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.createImageRenderer_ = function(source) {
|
function createImageRenderer(source) {
|
||||||
var layer = new _ol_layer_Image_({source: source});
|
var layer = new _ol_layer_Image_({source: source});
|
||||||
return new _ol_renderer_canvas_ImageLayer_(layer);
|
return new _ol_renderer_canvas_ImageLayer_(layer);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a tile renderer for the provided source.
|
* Create a tile renderer for the provided source.
|
||||||
* @param {ol.source.Tile} source The source.
|
* @param {ol.source.Tile} source The source.
|
||||||
* @return {ol.renderer.canvas.Layer} The renderer.
|
* @return {ol.renderer.canvas.Layer} The renderer.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.createTileRenderer_ = function(source) {
|
function createTileRenderer(source) {
|
||||||
var layer = new TileLayer({source: source});
|
var layer = new TileLayer({source: source});
|
||||||
return new _ol_renderer_canvas_TileLayer_(layer);
|
return new _ol_renderer_canvas_TileLayer_(layer);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -429,7 +441,7 @@ _ol_source_Raster_.createTileRenderer_ = function(source) {
|
|||||||
* @param {olx.FrameState} frameState The frame state.
|
* @param {olx.FrameState} frameState The frame state.
|
||||||
* @param {Object} data An object made available to operations.
|
* @param {Object} data An object made available to operations.
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.Event = function(type, frameState, data) {
|
RasterSource.Event = function(type, frameState, data) {
|
||||||
Event.call(this, type);
|
Event.call(this, type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,34 +467,15 @@ _ol_source_Raster_.Event = function(type, frameState, data) {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
||||||
};
|
};
|
||||||
inherits(_ol_source_Raster_.Event, Event);
|
inherits(RasterSource.Event, Event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_ol_source_Raster_.prototype.getImageInternal = function() {
|
RasterSource.prototype.getImageInternal = function() {
|
||||||
return null; // not implemented
|
return null; // not implemented
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
export default RasterSource;
|
||||||
* @enum {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_ol_source_Raster_.EventType_ = {
|
|
||||||
/**
|
|
||||||
* Triggered before operations are run.
|
|
||||||
* @event ol.source.Raster.Event#beforeoperations
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
BEFOREOPERATIONS: 'beforeoperations',
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered after operations are run.
|
|
||||||
* @event ol.source.Raster.Event#afteroperations
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
AFTEROPERATIONS: 'afteroperations'
|
|
||||||
};
|
|
||||||
export default _ol_source_Raster_;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import _ol_View_ from '../../../../src/ol/View.js';
|
import _ol_View_ from '../../../../src/ol/View.js';
|
||||||
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
|
||||||
import _ol_source_Raster_ from '../../../../src/ol/source/Raster.js';
|
import RasterSource from '../../../../src/ol/source/Raster.js';
|
||||||
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
|
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
|
where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
|
||||||
@@ -55,7 +55,7 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() {
|
|||||||
transition: 0
|
transition: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
var raster = new _ol_source_Raster_({
|
var raster = new RasterSource({
|
||||||
sources: [source],
|
sources: [source],
|
||||||
operation: function(pixels) {
|
operation: function(pixels) {
|
||||||
var pixel = pixels[0];
|
var pixel = pixels[0];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import _ol_View_ from '../../../../src/ol/View.js';
|
|||||||
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
|
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
|
||||||
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
|
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
|
||||||
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
|
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
|
||||||
import _ol_source_Raster_ from '../../../../src/ol/source/Raster.js';
|
import RasterSource from '../../../../src/ol/source/Raster.js';
|
||||||
import Source from '../../../../src/ol/source/Source.js';
|
import Source from '../../../../src/ol/source/Source.js';
|
||||||
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
|
import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js';
|
||||||
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
|
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
|
||||||
@@ -50,7 +50,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
|||||||
imageExtent: extent
|
imageExtent: extent
|
||||||
});
|
});
|
||||||
|
|
||||||
raster = new _ol_source_Raster_({
|
raster = new RasterSource({
|
||||||
threads: 0,
|
threads: 0,
|
||||||
sources: [redSource, greenSource, blueSource],
|
sources: [redSource, greenSource, blueSource],
|
||||||
operation: function(inputs) {
|
operation: function(inputs) {
|
||||||
@@ -90,19 +90,19 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
|
|
||||||
it('returns a tile source', function() {
|
it('returns a tile source', function() {
|
||||||
var source = new _ol_source_Raster_({
|
var source = new RasterSource({
|
||||||
threads: 0,
|
threads: 0,
|
||||||
sources: [new _ol_source_Tile_({})]
|
sources: [new _ol_source_Tile_({})]
|
||||||
});
|
});
|
||||||
expect(source).to.be.a(Source);
|
expect(source).to.be.a(Source);
|
||||||
expect(source).to.be.a(_ol_source_Raster_);
|
expect(source).to.be.a(RasterSource);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to "pixel" operation', function(done) {
|
it('defaults to "pixel" operation', function(done) {
|
||||||
|
|
||||||
var log = [];
|
var log = [];
|
||||||
|
|
||||||
var source = new _ol_source_Raster_({
|
var source = new RasterSource({
|
||||||
threads: 0,
|
threads: 0,
|
||||||
sources: [redSource, greenSource, blueSource],
|
sources: [redSource, greenSource, blueSource],
|
||||||
operation: function(inputs) {
|
operation: function(inputs) {
|
||||||
@@ -129,7 +129,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
|||||||
it('allows operation type to be set to "image"', function(done) {
|
it('allows operation type to be set to "image"', function(done) {
|
||||||
var log = [];
|
var log = [];
|
||||||
|
|
||||||
var source = new _ol_source_Raster_({
|
var source = new RasterSource({
|
||||||
operationType: 'image',
|
operationType: 'image',
|
||||||
threads: 0,
|
threads: 0,
|
||||||
sources: [redSource, greenSource, blueSource],
|
sources: [redSource, greenSource, blueSource],
|
||||||
@@ -315,7 +315,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
|
|||||||
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
|
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
|
||||||
});
|
});
|
||||||
|
|
||||||
raster = new _ol_source_Raster_({
|
raster = new RasterSource({
|
||||||
threads: 0,
|
threads: 0,
|
||||||
sources: [source],
|
sources: [source],
|
||||||
operation: function(inputs) {
|
operation: function(inputs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user