Base for image layers, renderer-specific image layer types

This commit is contained in:
Tim Schaub
2018-11-04 09:34:07 -07:00
parent c9529b9acd
commit 285a610c46
3 changed files with 126 additions and 38 deletions

69
src/ol/layer/BaseImage.js Normal file
View File

@@ -0,0 +1,69 @@
/**
* @module ol/layer/BaseImage
*/
import LayerType from '../LayerType.js';
import Layer from './Layer.js';
/**
* @typedef {Object} Options
* @property {number} [opacity=1] Opacity (0, 1).
* @property {boolean} [visible=true] Visibility.
* @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
* rendered outside of this extent.
* @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
* will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
* for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
* method was used.
* @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
* visible.
* @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
* be visible.
* @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
* this layer in its layers collection, and the layer will be rendered on top. This is useful for
* temporary layers. The standard way to add a layer to a map and have it managed by the map is to
* use {@link module:ol/Map#addLayer}.
* @property {import("../source/Image.js").default} [source] Source for this layer.
*/
/**
* @classdesc
* Server-rendered images that are available for arbitrary extents and
* resolutions.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @fires import("../render/Event.js").RenderEvent
* @api
*/
class BaseImageLayer extends Layer {
/**
* @param {Options=} opt_options Layer options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
super(options);
/**
* The layer type.
* @protected
* @type {import("../LayerType.js").default}
*/
this.type = LayerType.IMAGE;
}
}
/**
* Return the associated {@link module:ol/source/Image source} of the image layer.
* @function
* @return {import("../source/Image.js").default} Source.
* @api
*/
BaseImageLayer.prototype.getSource;
export default BaseImageLayer;

View File

@@ -1,29 +1,12 @@
/**
* @module ol/layer/Image
*/
import LayerType from '../LayerType.js';
import Layer from './Layer.js';
import BaseImageLayer from './BaseImage.js';
import CanvasImageLayerRenderer from '../renderer/canvas/ImageLayer.js';
/**
* @typedef {Object} Options
* @property {number} [opacity=1] Opacity (0, 1).
* @property {boolean} [visible=true] Visibility.
* @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
* rendered outside of this extent.
* @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
* will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
* for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
* method was used.
* @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
* visible.
* @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
* be visible.
* @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
* this layer in its layers collection, and the layer will be rendered on top. This is useful for
* temporary layers. The standard way to add a layer to a map and have it managed by the map is to
* use {@link module:ol/Map#addLayer}.
* @property {import("../source/Image.js").default} [source] Source for this layer.
* @typedef {import("./BaseImage.js").Options} Options
*/
@@ -38,32 +21,24 @@ import Layer from './Layer.js';
* @fires import("../render/Event.js").RenderEvent
* @api
*/
class ImageLayer extends Layer {
class ImageLayer extends BaseImageLayer {
/**
* @param {Options=} opt_options Layer options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
super(options);
/**
* The layer type.
* @protected
* @type {import("../LayerType.js").default}
*/
this.type = LayerType.IMAGE;
super(opt_options);
}
/**
* Create a renderer for this layer.
* @return {import("../renderer/Layer.js").default} A layer renderer.
* @protected
*/
createRenderer() {
return new CanvasImageLayerRenderer(this);
}
}
/**
* Return the associated {@link module:ol/source/Image source} of the image layer.
* @function
* @return {import("../source/Image.js").default} Source.
* @api
*/
ImageLayer.prototype.getSource;
export default ImageLayer;

View File

@@ -0,0 +1,44 @@
/**
* @module ol/layer/WebGLImage
*/
import BaseImageLayer from './BaseImage.js';
/**
* @typedef {import("./BaseImage.js").Options} Options
*/
/**
* @classdesc
* Server-rendered images that are available for arbitrary extents and
* resolutions.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @fires import("../render/Event.js").RenderEvent
* @api
*/
class WebGLImageLayer extends BaseImageLayer {
/**
* @param {Options=} opt_options Layer options.
*/
constructor(opt_options) {
super(opt_options);
}
/**
* Create a renderer for this layer.
* @return {import("../renderer/Layer.js").default} A layer renderer.
* @protected
*/
createRenderer() {
// TODO: rework WebGL renderers to share context
return null;
}
}
export default WebGLImageLayer;