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,8 +1,8 @@
/**
* @module ol/source/Image
*/
import {abstract} from '../util.js';
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
import ImageState from '../ImageState.js';
import {linearFindNearest} from '../array.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
* instantiated in apps.
* Base class for sources providing a single image.
* @abstract
* @api
*/
class ImageSource extends Source {
@@ -188,7 +189,9 @@ class ImageSource extends Source {
* @return {import("../ImageBase.js").default} Single image.
* @protected
*/
getImageInternal(extent, resolution, pixelRatio, projection) {}
getImageInternal(extent, resolution, pixelRatio, projection) {
return abstract();
}
/**
* Handle image change events.

View File

@@ -1,7 +1,7 @@
/**
* @module ol/source/Source
*/
import {abstract} from '../util.js';
import BaseObject from '../Object.js';
import {get as getProjection} from '../proj.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.
*
* A generic `change` event is triggered when the state of the source changes.
* @abstract
* @api
*/
class Source extends BaseObject {
@@ -123,7 +124,9 @@ class Source extends BaseObject {
* @abstract
* @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.

View File

@@ -1,7 +1,7 @@
/**
* @module ol/source/Tile
*/
import {abstract} from '../util.js';
import TileCache from '../TileCache.js';
import TileState from '../TileState.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
* instantiated in apps.
* Base class for sources providing images divided into a tile grid.
* @abstract
* @api
*/
class TileSource extends Source {
@@ -199,7 +200,9 @@ class TileSource extends Source {
* @param {import("../proj/Projection.js").default} projection Projection.
* @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.
@@ -292,8 +295,8 @@ class TileSource extends Source {
}
/**
* @abstract
* Marks a tile coord as being used, without triggering a load.
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.