Merge pull request #8868 from ahocevar/abstract-methods

Throw when calling abstract methods; fix abstract return types
This commit is contained in:
Andreas Hocevar
2018-10-31 12:07:01 +01:00
committed by GitHub
22 changed files with 273 additions and 85 deletions

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/ImageBase * @module ol/ImageBase
*/ */
import {abstract} from './util.js';
import EventTarget from './events/Target.js'; import EventTarget from './events/Target.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
@@ -63,7 +64,9 @@ class ImageBase extends EventTarget {
* @abstract * @abstract
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
*/ */
getImage() {} getImage() {
return abstract();
}
/** /**
* @return {number} PixelRatio. * @return {number} PixelRatio.
@@ -90,7 +93,9 @@ class ImageBase extends EventTarget {
* Load not yet loaded URI. * Load not yet loaded URI.
* @abstract * @abstract
*/ */
load() {} load() {
abstract();
}
} }

View File

@@ -2,6 +2,7 @@
* @module ol/format/Feature * @module ol/format/Feature
*/ */
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import {abstract} from '../util.js';
import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js'; import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js';
@@ -122,7 +123,9 @@ class FeatureFormat {
* @abstract * @abstract
* @return {import("./FormatType.js").default} Format. * @return {import("./FormatType.js").default} Format.
*/ */
getType() {} getType() {
return abstract();
}
/** /**
* Read a single feature from a source. * Read a single feature from a source.
@@ -132,7 +135,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options. * @param {ReadOptions=} opt_options Read options.
* @return {import("../Feature.js").FeatureLike} Feature. * @return {import("../Feature.js").FeatureLike} Feature.
*/ */
readFeature(source, opt_options) {} readFeature(source, opt_options) {
return abstract();
}
/** /**
* Read all features from a source. * Read all features from a source.
@@ -142,7 +147,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options. * @param {ReadOptions=} opt_options Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features. * @return {Array<import("../Feature.js").FeatureLike>} Features.
*/ */
readFeatures(source, opt_options) {} readFeatures(source, opt_options) {
return abstract();
}
/** /**
* Read a single geometry from a source. * Read a single geometry from a source.
@@ -152,7 +159,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options. * @param {ReadOptions=} opt_options Read options.
* @return {import("../geom/Geometry.js").default} Geometry. * @return {import("../geom/Geometry.js").default} Geometry.
*/ */
readGeometry(source, opt_options) {} readGeometry(source, opt_options) {
return abstract();
}
/** /**
* Read the projection from a source. * Read the projection from a source.
@@ -161,7 +170,9 @@ class FeatureFormat {
* @param {Document|Node|Object|string} source Source. * @param {Document|Node|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection. * @return {import("../proj/Projection.js").default} Projection.
*/ */
readProjection(source) {} readProjection(source) {
return abstract();
}
/** /**
* Encode a feature in this format. * Encode a feature in this format.
@@ -171,7 +182,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options. * @param {WriteOptions=} opt_options Write options.
* @return {string} Result. * @return {string} Result.
*/ */
writeFeature(feature, opt_options) {} writeFeature(feature, opt_options) {
return abstract();
}
/** /**
* Encode an array of features in this format. * Encode an array of features in this format.
@@ -181,7 +194,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options. * @param {WriteOptions=} opt_options Write options.
* @return {string} Result. * @return {string} Result.
*/ */
writeFeatures(features, opt_options) {} writeFeatures(features, opt_options) {
return abstract();
}
/** /**
* Write a single geometry in this format. * Write a single geometry in this format.
@@ -191,7 +206,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options. * @param {WriteOptions=} opt_options Write options.
* @return {string} Result. * @return {string} Result.
*/ */
writeGeometry(geometry, opt_options) {} writeGeometry(geometry, opt_options) {
return abstract();
}
} }
export default FeatureFormat; export default FeatureFormat;

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/format/JSONFeature * @module ol/format/JSONFeature
*/ */
import {abstract} from '../util.js';
import FeatureFormat from '../format/Feature.js'; import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js'; import FormatType from '../format/FormatType.js';
@@ -59,7 +60,9 @@ class JSONFeature extends FeatureFormat {
* @protected * @protected
* @return {import("../Feature.js").default} Feature. * @return {import("../Feature.js").default} Feature.
*/ */
readFeatureFromObject(object, opt_options) {} readFeatureFromObject(object, opt_options) {
return abstract();
}
/** /**
* @abstract * @abstract
@@ -68,7 +71,9 @@ class JSONFeature extends FeatureFormat {
* @protected * @protected
* @return {Array<import("../Feature.js").default>} Features. * @return {Array<import("../Feature.js").default>} Features.
*/ */
readFeaturesFromObject(object, opt_options) {} readFeaturesFromObject(object, opt_options) {
return abstract();
}
/** /**
* Read a geometry. * Read a geometry.
@@ -90,7 +95,9 @@ class JSONFeature extends FeatureFormat {
* @protected * @protected
* @return {import("../geom/Geometry.js").default} Geometry. * @return {import("../geom/Geometry.js").default} Geometry.
*/ */
readGeometryFromObject(object, opt_options) {} readGeometryFromObject(object, opt_options) {
return abstract();
}
/** /**
* Read the projection. * Read the projection.
@@ -109,7 +116,9 @@ class JSONFeature extends FeatureFormat {
* @protected * @protected
* @return {import("../proj/Projection.js").default} Projection. * @return {import("../proj/Projection.js").default} Projection.
*/ */
readProjectionFromObject(object) {} readProjectionFromObject(object) {
return abstract();
}
/** /**
* Encode a feature as string. * Encode a feature as string.
@@ -129,7 +138,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object. * @return {Object} Object.
*/ */
writeFeatureObject(feature, opt_options) {} writeFeatureObject(feature, opt_options) {
return abstract();
}
/** /**
* Encode an array of features as string. * Encode an array of features as string.
@@ -149,7 +160,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object. * @return {Object} Object.
*/ */
writeFeaturesObject(features, opt_options) {} writeFeaturesObject(features, opt_options) {
return abstract();
}
/** /**
* Encode a geometry as string. * Encode a geometry as string.
@@ -169,7 +182,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options. * @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object. * @return {Object} Object.
*/ */
writeGeometryObject(geometry, opt_options) {} writeGeometryObject(geometry, opt_options) {
return abstract();
}
} }

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/format/TextFeature * @module ol/format/TextFeature
*/ */
import {abstract} from '../util.js';
import FeatureFormat from '../format/Feature.js'; import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js'; import FormatType from '../format/FormatType.js';
@@ -43,7 +44,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {import("../Feature.js").default} Feature. * @return {import("../Feature.js").default} Feature.
*/ */
readFeatureFromText(text, opt_options) {} readFeatureFromText(text, opt_options) {
return abstract();
}
/** /**
* Read the features from the source. * Read the features from the source.
@@ -64,7 +67,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {Array<import("../Feature.js").default>} Features. * @return {Array<import("../Feature.js").default>} Features.
*/ */
readFeaturesFromText(text, opt_options) {} readFeaturesFromText(text, opt_options) {
return abstract();
}
/** /**
* Read the geometry from the source. * Read the geometry from the source.
@@ -85,7 +90,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {import("../geom/Geometry.js").default} Geometry. * @return {import("../geom/Geometry.js").default} Geometry.
*/ */
readGeometryFromText(text, opt_options) {} readGeometryFromText(text, opt_options) {
return abstract();
}
/** /**
* Read the projection from the source. * Read the projection from the source.
@@ -126,7 +133,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {string} Text. * @return {string} Text.
*/ */
writeFeatureText(feature, opt_options) {} writeFeatureText(feature, opt_options) {
return abstract();
}
/** /**
* Encode an array of features as string. * Encode an array of features as string.
@@ -147,7 +156,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {string} Text. * @return {string} Text.
*/ */
writeFeaturesText(features, opt_options) {} writeFeaturesText(features, opt_options) {
return abstract();
}
/** /**
* Write a single geometry. * Write a single geometry.
@@ -168,7 +179,9 @@ class TextFeature extends FeatureFormat {
* @protected * @protected
* @return {string} Text. * @return {string} Text.
*/ */
writeGeometryText(geometry, opt_options) {} writeGeometryText(geometry, opt_options) {
return abstract();
}
} }

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/format/XMLFeature * @module ol/format/XMLFeature
*/ */
import {abstract} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import FeatureFormat from '../format/Feature.js'; import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js'; import FormatType from '../format/FormatType.js';
@@ -122,7 +123,9 @@ class XMLFeature extends FeatureFormat {
* @protected * @protected
* @return {Array<import("../Feature.js").default>} Features. * @return {Array<import("../Feature.js").default>} Features.
*/ */
readFeaturesFromNode(node, opt_options) {} readFeaturesFromNode(node, opt_options) {
return abstract();
}
/** /**
* @inheritDoc * @inheritDoc

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/geom/Geometry * @module ol/geom/Geometry
*/ */
import {abstract} from '../util.js';
import BaseObject from '../Object.js'; import BaseObject from '../Object.js';
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js'; import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
import {transform2D} from '../geom/flat/transform.js'; import {transform2D} from '../geom/flat/transform.js';
@@ -69,7 +70,9 @@ class Geometry extends BaseObject {
* @abstract * @abstract
* @return {!Geometry} Clone. * @return {!Geometry} Clone.
*/ */
clone() {} clone() {
return abstract();
}
/** /**
* @abstract * @abstract
@@ -79,7 +82,9 @@ class Geometry extends BaseObject {
* @param {number} minSquaredDistance Minimum squared distance. * @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance. * @return {number} Minimum squared distance.
*/ */
closestPointXY(x, y, closestPoint, minSquaredDistance) {} closestPointXY(x, y, closestPoint, minSquaredDistance) {
return abstract();
}
/** /**
* @param {number} x X. * @param {number} x X.
@@ -121,7 +126,9 @@ class Geometry extends BaseObject {
* @protected * @protected
* @return {import("../extent.js").Extent} extent Extent. * @return {import("../extent.js").Extent} extent Extent.
*/ */
computeExtent(extent) {} computeExtent(extent) {
return abstract();
}
/** /**
* Get the extent of the geometry. * Get the extent of the geometry.
@@ -145,7 +152,9 @@ class Geometry extends BaseObject {
* @param {import("../coordinate.js").Coordinate} anchor The rotation center. * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
* @api * @api
*/ */
rotate(angle, anchor) {} rotate(angle, anchor) {
abstract();
}
/** /**
* Scale the geometry (with an optional origin). This modifies the geometry * Scale the geometry (with an optional origin). This modifies the geometry
@@ -158,7 +167,9 @@ class Geometry extends BaseObject {
* of the geometry extent). * of the geometry extent).
* @api * @api
*/ */
scale(sx, opt_sy, opt_anchor) {} scale(sx, opt_sy, opt_anchor) {
abstract();
}
/** /**
* Create a simplified version of this geometry. For linestrings, this uses * Create a simplified version of this geometry. For linestrings, this uses
@@ -182,14 +193,18 @@ class Geometry extends BaseObject {
* @param {number} squaredTolerance Squared tolerance. * @param {number} squaredTolerance Squared tolerance.
* @return {Geometry} Simplified geometry. * @return {Geometry} Simplified geometry.
*/ */
getSimplifiedGeometry(squaredTolerance) {} getSimplifiedGeometry(squaredTolerance) {
return abstract();
}
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @abstract * @abstract
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./GeometryType.js").default} Geometry type.
*/ */
getType() {} getType() {
return abstract();
}
/** /**
* Apply a transform function to each coordinate of the geometry. * Apply a transform function to each coordinate of the geometry.
@@ -199,7 +214,9 @@ class Geometry extends BaseObject {
* @abstract * @abstract
* @param {import("../proj.js").TransformFunction} transformFn Transform. * @param {import("../proj.js").TransformFunction} transformFn Transform.
*/ */
applyTransform(transformFn) {} applyTransform(transformFn) {
abstract();
}
/** /**
* Test if the geometry and the passed extent intersect. * Test if the geometry and the passed extent intersect.
@@ -207,7 +224,9 @@ class Geometry extends BaseObject {
* @param {import("../extent.js").Extent} extent Extent. * @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect. * @return {boolean} `true` if the geometry and the extent intersect.
*/ */
intersectsExtent(extent) {} intersectsExtent(extent) {
return abstract();
}
/** /**
* Translate the geometry. This modifies the geometry coordinates in place. If * Translate the geometry. This modifies the geometry coordinates in place. If
@@ -217,7 +236,9 @@ class Geometry extends BaseObject {
* @param {number} deltaY Delta Y. * @param {number} deltaY Delta Y.
* @api * @api
*/ */
translate(deltaX, deltaY) {} translate(deltaX, deltaY) {
abstract();
}
/** /**
* Transform each coordinate of the geometry from one coordinate reference * Transform each coordinate of the geometry from one coordinate reference

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/geom/SimpleGeometry * @module ol/geom/SimpleGeometry
*/ */
import {abstract} from '../util.js';
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js'; import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
import Geometry from '../geom/Geometry.js'; import Geometry from '../geom/Geometry.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -52,7 +53,9 @@ class SimpleGeometry extends Geometry {
* @abstract * @abstract
* @return {Array} Coordinates. * @return {Array} Coordinates.
*/ */
getCoordinates() {} getCoordinates() {
return abstract();
}
/** /**
* Return the first coordinate of the geometry. * Return the first coordinate of the geometry.
@@ -158,7 +161,9 @@ class SimpleGeometry extends Geometry {
* @param {!Array} coordinates Coordinates. * @param {!Array} coordinates Coordinates.
* @param {GeometryLayout=} opt_layout Layout. * @param {GeometryLayout=} opt_layout Layout.
*/ */
setCoordinates(coordinates, opt_layout) {} setCoordinates(coordinates, opt_layout) {
abstract();
}
/** /**
* @param {GeometryLayout|undefined} layout Layout. * @param {GeometryLayout|undefined} layout Layout.

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/layer/Base * @module ol/layer/Base
*/ */
import {abstract} from '../util.js';
import BaseObject from '../Object.js'; import BaseObject from '../Object.js';
import LayerProperty from '../layer/Property.js'; import LayerProperty from '../layer/Property.js';
import {clamp} from '../math.js'; import {clamp} from '../math.js';
@@ -105,7 +106,9 @@ class BaseLayer extends BaseObject {
* modified in place). * modified in place).
* @return {Array<import("./Layer.js").default>} Array of layers. * @return {Array<import("./Layer.js").default>} Array of layers.
*/ */
getLayersArray(opt_array) {} getLayersArray(opt_array) {
return abstract();
}
/** /**
* @abstract * @abstract
@@ -113,7 +116,9 @@ class BaseLayer extends BaseObject {
* states (to be modified in place). * states (to be modified in place).
* @return {Array<import("./Layer.js").State>} List of layer states. * @return {Array<import("./Layer.js").State>} List of layer states.
*/ */
getLayerStatesArray(opt_states) {} getLayerStatesArray(opt_states) {
return abstract();
}
/** /**
* Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it * Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it
@@ -162,7 +167,9 @@ class BaseLayer extends BaseObject {
* @abstract * @abstract
* @return {import("../source/State.js").default} Source state. * @return {import("../source/State.js").default} Source state.
*/ */
getSourceState() {} getSourceState() {
return abstract();
}
/** /**
* Return the visibility of the layer (`true` or `false`). * Return the visibility of the layer (`true` or `false`).

View File

@@ -1,6 +1,8 @@
/** /**
* @module ol/render/ReplayGroup * @module ol/render/ReplayGroup
*/ */
import {abstract} from '../util.js';
/** /**
* Base class for replay groups. * Base class for replay groups.
*/ */
@@ -11,20 +13,26 @@ class ReplayGroup {
* @param {import("./ReplayType.js").default} replayType Replay type. * @param {import("./ReplayType.js").default} replayType Replay type.
* @return {import("./VectorContext.js").default} Replay. * @return {import("./VectorContext.js").default} Replay.
*/ */
getReplay(zIndex, replayType) {} getReplay(zIndex, replayType) {
return abstract();
}
/** /**
* @abstract * @abstract
* @return {boolean} Is empty. * @return {boolean} Is empty.
*/ */
isEmpty() {} isEmpty() {
return abstract();
}
/** /**
* @abstract * @abstract
* @param {boolean} group Group with previous replay * @param {boolean} group Group with previous replay
* @return {Array<*>} The resulting instruction group * @return {Array<*>} The resulting instruction group
*/ */
addDeclutter(group) {} addDeclutter(group) {
return abstract();
}
} }
export default ReplayGroup; export default ReplayGroup;

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/render/webgl/Replay * @module ol/render/webgl/Replay
*/ */
import {abstract} from '../../util.js';
import {getCenter} from '../../extent.js'; import {getCenter} from '../../extent.js';
import VectorContext from '../VectorContext.js'; import VectorContext from '../VectorContext.js';
import { import {
@@ -122,13 +122,17 @@ class WebGLReplay extends VectorContext {
* @param {import("../../webgl/Context.js").default} context WebGL context. * @param {import("../../webgl/Context.js").default} context WebGL context.
* @return {function()} Delete resources function. * @return {function()} Delete resources function.
*/ */
getDeleteResourcesFunction(context) {} getDeleteResourcesFunction(context) {
return abstract();
}
/** /**
* @abstract * @abstract
* @param {import("../../webgl/Context.js").default} context Context. * @param {import("../../webgl/Context.js").default} context Context.
*/ */
finish(context) {} finish(context) {
abstract();
}
/** /**
* @abstract * @abstract
@@ -142,7 +146,9 @@ class WebGLReplay extends VectorContext {
import("./polygonreplay/defaultshader/Locations.js").default| import("./polygonreplay/defaultshader/Locations.js").default|
import("./texturereplay/defaultshader/Locations.js").default} Locations. import("./texturereplay/defaultshader/Locations.js").default} Locations.
*/ */
setUpProgram(gl, context, size, pixelRatio) {} setUpProgram(gl, context, size, pixelRatio) {
return abstract();
}
/** /**
* @abstract * @abstract
@@ -153,7 +159,9 @@ class WebGLReplay extends VectorContext {
import("./polygonreplay/defaultshader/Locations.js").default| import("./polygonreplay/defaultshader/Locations.js").default|
import("./texturereplay/defaultshader/Locations.js").default} locations Locations. import("./texturereplay/defaultshader/Locations.js").default} locations Locations.
*/ */
shutDownProgram(gl, locations) {} shutDownProgram(gl, locations) {
abstract();
}
/** /**
* @abstract * @abstract
@@ -163,7 +171,9 @@ class WebGLReplay extends VectorContext {
* @param {Object<string, boolean>} skippedFeaturesHash Ids of features to skip. * @param {Object<string, boolean>} skippedFeaturesHash Ids of features to skip.
* @param {boolean} hitDetection Hit detection mode. * @param {boolean} hitDetection Hit detection mode.
*/ */
drawReplay(gl, context, skippedFeaturesHash, hitDetection) {} drawReplay(gl, context, skippedFeaturesHash, hitDetection) {
abstract();
}
/** /**
* @abstract * @abstract
@@ -176,7 +186,9 @@ class WebGLReplay extends VectorContext {
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template T * @template T
*/ */
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {} drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {
return abstract();
}
/** /**
* @protected * @protected

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/render/webgl/TextureReplay * @module ol/render/webgl/TextureReplay
*/ */
import {getUid} from '../../util.js'; import {abstract, getUid} from '../../util.js';
import {intersects} from '../../extent.js'; import {intersects} from '../../extent.js';
import {isEmpty} from '../../obj.js'; import {isEmpty} from '../../obj.js';
import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js'; import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js';
@@ -460,16 +460,20 @@ class WebGLTextureReplay extends WebGLReplay {
* @abstract * @abstract
* @protected * @protected
* @param {boolean=} opt_all Return hit detection textures with regular ones. * @param {boolean=} opt_all Return hit detection textures with regular ones.
* @returns {Array<WebGLTexture>} Textures. * @return {Array<WebGLTexture>} Textures.
*/ */
getTextures(opt_all) {} getTextures(opt_all) {
return abstract();
}
/** /**
* @abstract * @abstract
* @protected * @protected
* @returns {Array<WebGLTexture>} Textures. * @return {Array<WebGLTexture>} Textures.
*/ */
getHitDetectionTextures() {} getHitDetectionTextures() {
return abstract();
}
} }

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/renderer/Map * @module ol/renderer/Map
*/ */
import {getUid} from '../util.js'; import {abstract, getUid} from '../util.js';
import Disposable from '../Disposable.js'; import Disposable from '../Disposable.js';
import {listen, unlistenByKey} from '../events.js'; import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
@@ -11,7 +11,9 @@ import {visibleAtResolution} from '../layer/Layer.js';
import {shared as iconImageCache} from '../style/IconImageCache.js'; import {shared as iconImageCache} from '../style/IconImageCache.js';
import {compose as composeTransform, invert as invertTransform, setFromArray as transformSetFromArray} from '../transform.js'; import {compose as composeTransform, invert as invertTransform, setFromArray as transformSetFromArray} from '../transform.js';
/**
* @abstract
*/
class MapRenderer extends Disposable { class MapRenderer extends Disposable {
/** /**
@@ -51,7 +53,9 @@ class MapRenderer extends Disposable {
* @param {import("../render/EventType.js").default} type Event type. * @param {import("../render/EventType.js").default} type Event type.
* @param {import("../PluggableMap.js").FrameState} frameState Frame state. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.
*/ */
dispatchRenderEvent(type, frameState) {} dispatchRenderEvent(type, frameState) {
abstract();
}
/** /**
* Register layer renderer constructors. * Register layer renderer constructors.
@@ -179,7 +183,9 @@ class MapRenderer extends Disposable {
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T,U * @template S,T,U
*/ */
forEachLayerAtPixel(pixel, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) {} forEachLayerAtPixel(pixel, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) {
return abstract();
}
/** /**
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate. * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
@@ -290,11 +296,13 @@ class MapRenderer extends Disposable {
} }
/** /**
* @abstract
* Render. * Render.
* @abstract
* @param {?import("../PluggableMap.js").FrameState} frameState Frame state. * @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
*/ */
renderFrame(frameState) {} renderFrame(frameState) {
abstract();
}
/** /**
* @param {import("../PluggableMap.js").FrameState} frameState Frame state. * @param {import("../PluggableMap.js").FrameState} frameState Frame state.

View File

@@ -1,12 +1,16 @@
/** /**
* @module ol/renderer/canvas/IntermediateCanvas * @module ol/renderer/canvas/IntermediateCanvas
*/ */
import {abstract} from '../../util.js';
import {scale as scaleCoordinate} from '../../coordinate.js'; import {scale as scaleCoordinate} from '../../coordinate.js';
import {createCanvasContext2D} from '../../dom.js'; import {createCanvasContext2D} from '../../dom.js';
import {containsExtent, intersects} from '../../extent.js'; import {containsExtent, intersects} from '../../extent.js';
import CanvasLayerRenderer from '../canvas/Layer.js'; import CanvasLayerRenderer from '../canvas/Layer.js';
import {create as createTransform, apply as applyTransform} from '../../transform.js'; import {create as createTransform, apply as applyTransform} from '../../transform.js';
/**
* @abstract
*/
class IntermediateCanvasRenderer extends CanvasLayerRenderer { class IntermediateCanvasRenderer extends CanvasLayerRenderer {
/** /**
@@ -80,13 +84,17 @@ class IntermediateCanvasRenderer extends CanvasLayerRenderer {
* @abstract * @abstract
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Canvas. * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Canvas.
*/ */
getImage() {} getImage() {
return abstract();
}
/** /**
* @abstract * @abstract
* @return {!import("../../transform.js").Transform} Image transform. * @return {!import("../../transform.js").Transform} Image transform.
*/ */
getImageTransform() {} getImageTransform() {
return abstract();
}
/** /**
* @inheritDoc * @inheritDoc

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/renderer/canvas/Layer * @module ol/renderer/canvas/Layer
*/ */
import {abstract} from '../../util.js';
import {getBottomLeft, getBottomRight, getTopLeft, getTopRight} from '../../extent.js'; import {getBottomLeft, getBottomRight, getTopLeft, getTopRight} from '../../extent.js';
import {TRUE} from '../../functions.js'; import {TRUE} from '../../functions.js';
import RenderEvent from '../../render/Event.js'; import RenderEvent from '../../render/Event.js';
@@ -10,6 +11,9 @@ import CanvasImmediateRenderer from '../../render/canvas/Immediate.js';
import LayerRenderer from '../Layer.js'; import LayerRenderer from '../Layer.js';
import {create as createTransform, apply as applyTransform, compose as composeTransform} from '../../transform.js'; import {create as createTransform, apply as applyTransform, compose as composeTransform} from '../../transform.js';
/**
* @abstract
*/
class CanvasLayerRenderer extends LayerRenderer { class CanvasLayerRenderer extends LayerRenderer {
/** /**
@@ -167,7 +171,9 @@ class CanvasLayerRenderer extends LayerRenderer {
* @param {import("../../layer/Layer.js").State} layerState Layer state. * @param {import("../../layer/Layer.js").State} layerState Layer state.
* @param {CanvasRenderingContext2D} context Context. * @param {CanvasRenderingContext2D} context Context.
*/ */
composeFrame(frameState, layerState, context) {} composeFrame(frameState, layerState, context) {
abstract();
}
/** /**
* @abstract * @abstract
@@ -175,7 +181,9 @@ class CanvasLayerRenderer extends LayerRenderer {
* @param {import("../../layer/Layer.js").State} layerState Layer state. * @param {import("../../layer/Layer.js").State} layerState Layer state.
* @return {boolean} whether composeFrame should be called. * @return {boolean} whether composeFrame should be called.
*/ */
prepareFrame(frameState, layerState) {} prepareFrame(frameState, layerState) {
return abstract();
}
} }
export default CanvasLayerRenderer; export default CanvasLayerRenderer;

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/renderer/webgl/Layer * @module ol/renderer/webgl/Layer
*/ */
import {abstract} from '../../util.js';
import RenderEvent from '../../render/Event.js'; import RenderEvent from '../../render/Event.js';
import RenderEventType from '../../render/EventType.js'; import RenderEventType from '../../render/EventType.js';
import WebGLImmediateRenderer from '../../render/webgl/Immediate.js'; import WebGLImmediateRenderer from '../../render/webgl/Immediate.js';
@@ -14,6 +15,9 @@ import {ARRAY_BUFFER, FRAMEBUFFER, FLOAT, TEXTURE_2D,
import WebGLBuffer from '../../webgl/Buffer.js'; import WebGLBuffer from '../../webgl/Buffer.js';
import {createEmptyTexture} from '../../webgl/Context.js'; import {createEmptyTexture} from '../../webgl/Context.js';
/**
* @abstract
*/
class WebGLLayerRenderer extends LayerRenderer { class WebGLLayerRenderer extends LayerRenderer {
/** /**
@@ -236,7 +240,9 @@ class WebGLLayerRenderer extends LayerRenderer {
* @param {import("../../webgl/Context.js").default} context Context. * @param {import("../../webgl/Context.js").default} context Context.
* @return {boolean} whether composeFrame should be called. * @return {boolean} whether composeFrame should be called.
*/ */
prepareFrame(frameState, layerState, context) {} prepareFrame(frameState, layerState, context) {
return abstract();
}
/** /**
* @abstract * @abstract
@@ -248,7 +254,9 @@ class WebGLLayerRenderer extends LayerRenderer {
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T,U * @template S,T,U
*/ */
forEachLayerAtPixel(pixel, frameState, callback, thisArg) {} forEachLayerAtPixel(pixel, frameState, callback, thisArg) {
return abstract();
}
} }

View File

@@ -1,8 +1,8 @@
/** /**
* @module ol/source/Image * @module ol/source/Image
*/ */
import {abstract} from '../util.js';
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
import {linearFindNearest} from '../array.js'; import {linearFindNearest} from '../array.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
@@ -81,6 +81,7 @@ class ImageSourceEvent extends Event {
* Abstract base class; normally only used for creating subclasses and not * Abstract base class; normally only used for creating subclasses and not
* instantiated in apps. * instantiated in apps.
* Base class for sources providing a single image. * Base class for sources providing a single image.
* @abstract
* @api * @api
*/ */
class ImageSource extends Source { class ImageSource extends Source {
@@ -188,7 +189,9 @@ class ImageSource extends Source {
* @return {import("../ImageBase.js").default} Single image. * @return {import("../ImageBase.js").default} Single image.
* @protected * @protected
*/ */
getImageInternal(extent, resolution, pixelRatio, projection) {} getImageInternal(extent, resolution, pixelRatio, projection) {
return abstract();
}
/** /**
* Handle image change events. * Handle image change events.

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/source/Source * @module ol/source/Source
*/ */
import {abstract} from '../util.js';
import BaseObject from '../Object.js'; import BaseObject from '../Object.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import SourceState from './State.js'; import SourceState from './State.js';
@@ -44,6 +44,7 @@ import SourceState from './State.js';
* Base class for {@link module:ol/layer/Layer~Layer} sources. * Base class for {@link module:ol/layer/Layer~Layer} sources.
* *
* A generic `change` event is triggered when the state of the source changes. * A generic `change` event is triggered when the state of the source changes.
* @abstract
* @api * @api
*/ */
class Source extends BaseObject { class Source extends BaseObject {
@@ -123,7 +124,9 @@ class Source extends BaseObject {
* @abstract * @abstract
* @return {Array<number>|undefined} Resolutions. * @return {Array<number>|undefined} Resolutions.
*/ */
getResolutions() {} getResolutions() {
return abstract();
}
/** /**
* Get the state of the source, see {@link module:ol/source/State~State} for possible states. * Get the state of the source, see {@link module:ol/source/State~State} for possible states.

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/source/Tile * @module ol/source/Tile
*/ */
import {abstract} from '../util.js';
import TileCache from '../TileCache.js'; import TileCache from '../TileCache.js';
import TileState from '../TileState.js'; import TileState from '../TileState.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
@@ -31,6 +31,7 @@ import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.j
* Abstract base class; normally only used for creating subclasses and not * Abstract base class; normally only used for creating subclasses and not
* instantiated in apps. * instantiated in apps.
* Base class for sources providing images divided into a tile grid. * Base class for sources providing images divided into a tile grid.
* @abstract
* @api * @api
*/ */
class TileSource extends Source { class TileSource extends Source {
@@ -199,7 +200,9 @@ class TileSource extends Source {
* @param {import("../proj/Projection.js").default} projection Projection. * @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../Tile.js").default} Tile. * @return {!import("../Tile.js").default} Tile.
*/ */
getTile(z, x, y, pixelRatio, projection) {} getTile(z, x, y, pixelRatio, projection) {
return abstract();
}
/** /**
* Return the tile grid of the tile source. * Return the tile grid of the tile source.
@@ -292,8 +295,8 @@ class TileSource extends Source {
} }
/** /**
* @abstract
* Marks a tile coord as being used, without triggering a load. * Marks a tile coord as being used, without triggering a load.
* @abstract
* @param {number} z Tile coordinate z. * @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x. * @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y. * @param {number} y Tile coordinate y.

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/style/Image * @module ol/style/Image
*/ */
import {abstract} from '../util.js';
/** /**
@@ -17,6 +18,7 @@
* A base class used for creating subclasses and not instantiated in * A base class used for creating subclasses and not instantiated in
* apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and
* {@link module:ol/style/RegularShape~RegularShape}. * {@link module:ol/style/RegularShape~RegularShape}.
* @abstract
* @api * @api
*/ */
class ImageStyle { class ImageStyle {
@@ -117,7 +119,9 @@ class ImageStyle {
* @abstract * @abstract
* @return {Array<number>} Anchor. * @return {Array<number>} Anchor.
*/ */
getAnchor() {} getAnchor() {
return abstract();
}
/** /**
* Get the image element for the symbolizer. * Get the image element for the symbolizer.
@@ -125,46 +129,60 @@ class ImageStyle {
* @param {number} pixelRatio Pixel ratio. * @param {number} pixelRatio Pixel ratio.
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element. * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
*/ */
getImage(pixelRatio) {} getImage(pixelRatio) {
return abstract();
}
/** /**
* @abstract * @abstract
* @param {number} pixelRatio Pixel ratio. * @param {number} pixelRatio Pixel ratio.
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element. * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
*/ */
getHitDetectionImage(pixelRatio) {} getHitDetectionImage(pixelRatio) {
return abstract();
}
/** /**
* @abstract * @abstract
* @return {import("../ImageState.js").default} Image state. * @return {import("../ImageState.js").default} Image state.
*/ */
getImageState() {} getImageState() {
return abstract();
}
/** /**
* @abstract * @abstract
* @return {import("../size.js").Size} Image size. * @return {import("../size.js").Size} Image size.
*/ */
getImageSize() {} getImageSize() {
return abstract();
}
/** /**
* @abstract * @abstract
* @return {import("../size.js").Size} Size of the hit-detection image. * @return {import("../size.js").Size} Size of the hit-detection image.
*/ */
getHitDetectionImageSize() {} getHitDetectionImageSize() {
return abstract();
}
/** /**
* Get the origin of the symbolizer. * Get the origin of the symbolizer.
* @abstract * @abstract
* @return {Array<number>} Origin. * @return {Array<number>} Origin.
*/ */
getOrigin() {} getOrigin() {
return abstract();
}
/** /**
* Get the size of the symbolizer (in pixels). * Get the size of the symbolizer (in pixels).
* @abstract * @abstract
* @return {import("../size.js").Size} Size. * @return {import("../size.js").Size} Size.
*/ */
getSize() {} getSize() {
return abstract();
}
/** /**
* Set the opacity. * Set the opacity.
@@ -220,13 +238,17 @@ class ImageStyle {
* @return {import("../events.js").EventsKey|undefined} Listener key. * @return {import("../events.js").EventsKey|undefined} Listener key.
* @template T * @template T
*/ */
listenImageChange(listener, thisArg) {} listenImageChange(listener, thisArg) {
return abstract();
}
/** /**
* Load not yet loaded URI. * Load not yet loaded URI.
* @abstract * @abstract
*/ */
load() {} load() {
abstract();
}
/** /**
* @abstract * @abstract
@@ -234,7 +256,9 @@ class ImageStyle {
* @param {T} thisArg Value to use as `this` when executing `listener`. * @param {T} thisArg Value to use as `this` when executing `listener`.
* @template T * @template T
*/ */
unlistenImageChange(listener, thisArg) {} unlistenImageChange(listener, thisArg) {
abstract();
}
} }
export default ImageStyle; export default ImageStyle;

View File

@@ -2,6 +2,15 @@
* @module ol/util * @module ol/util
*/ */
/**
* @return {?} Any return.
*/
export function abstract() {
return /** @type {?} */ ((function() {
throw new Error('Unimplemented abstract method.');
})());
}
/** /**
* Inherit the prototype methods from one constructor into another. * Inherit the prototype methods from one constructor into another.
* *

View File

@@ -1,6 +1,7 @@
/** /**
* @module ol/webgl/Shader * @module ol/webgl/Shader
*/ */
import {abstract} from '../util.js';
/** /**
* @abstract * @abstract
@@ -31,7 +32,9 @@ class WebGLShader {
* @abstract * @abstract
* @return {number} Type. * @return {number} Type.
*/ */
getType() {} getType() {
return abstract();
}
/** /**
* @return {string} Source. * @return {string} Source.

View File

@@ -4,6 +4,7 @@ describe('ol.render.Replay', function() {
let replay; let replay;
beforeEach(function() { beforeEach(function() {
replay = new WebGLReplay(5, [-180, -90, 180, 90]); replay = new WebGLReplay(5, [-180, -90, 180, 90]);
replay.drawReplay = replay.shutDownProgram = function() {};
}); });