Handle concrete classes with non implemented abstract methods

This commit is contained in:
Guillaume Beraudo
2017-01-13 23:39:39 +01:00
parent 7a7c01a074
commit b54ea89395
8 changed files with 105 additions and 13 deletions
+8
View File
@@ -223,3 +223,11 @@ ol.format.IGC.prototype.writeFeaturesText = function(features, opt_options) {};
* @inheritDoc * @inheritDoc
*/ */
ol.format.IGC.prototype.writeGeometryText = function(geometry, opt_options) {}; ol.format.IGC.prototype.writeGeometryText = function(geometry, opt_options) {};
/**
* @override
*/
ol.format.IGC.prototype.readGeometryFromText = function() {
throw new Error('Not implemented');
};
+40
View File
@@ -253,3 +253,43 @@ ol.format.MVT.readGeometry_ = function(rawFeature) {
return geom; return geom;
}; };
/**
* @override
*/
ol.format.MVT.prototype.readFeature = function() {
throw new Error('Not implemented');
};
/**
* @override
*/
ol.format.MVT.prototype.readGeometry = function() {
throw new Error('Not implemented');
};
/**
* @override
*/
ol.format.MVT.prototype.writeFeature = function() {
throw new Error('Not implemented');
};
/**
* @override
*/
ol.format.MVT.prototype.writeGeometry = function() {
throw new Error('Not implemented');
};
/**
* @override
*/
ol.format.MVT.prototype.writeFeatures = function() {
throw new Error('Not implemented');
};
+16
View File
@@ -416,3 +416,19 @@ ol.format.TopoJSON.prototype.writeFeaturesObject = function(features, opt_option
* @inheritDoc * @inheritDoc
*/ */
ol.format.TopoJSON.prototype.writeGeometryObject = function(geometry, opt_options) {}; ol.format.TopoJSON.prototype.writeGeometryObject = function(geometry, opt_options) {};
/**
* @override
*/
ol.format.TopoJSON.prototype.readGeometryFromObject = function() {
throw new Error('Not implemented');
};
/**
* @override
*/
ol.format.TopoJSON.prototype.readFeatureFromObject = function() {
throw new Error('Not implemented');
};
+21 -12
View File
@@ -7,6 +7,9 @@ goog.require('ol.format.FormatType');
goog.require('ol.xml'); goog.require('ol.xml');
/* eslint-disable valid-jsdoc */
/** /**
* @classdesc * @classdesc
* Abstract base class; normally only used for creating subclasses and not * Abstract base class; normally only used for creating subclasses and not
@@ -73,12 +76,13 @@ ol.format.XMLFeature.prototype.readFeatureFromDocument = function(
/** /**
* @abstract
* @param {Node} node Node. * @param {Node} node Node.
* @param {olx.format.ReadOptions=} opt_options Options. * @param {olx.format.ReadOptions=} opt_options Options.
* @return {ol.Feature} Feature. * @return {ol.Feature} Feature.
*/ */
ol.format.XMLFeature.prototype.readFeatureFromNode = function(node, opt_options) {}; ol.format.XMLFeature.prototype.readFeatureFromNode = function(node, opt_options) {
throw new Error('Not implemented');
};
/** /**
@@ -148,23 +152,25 @@ ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
/** /**
* @abstract
* @param {Document} doc Document. * @param {Document} doc Document.
* @param {olx.format.ReadOptions=} opt_options Options. * @param {olx.format.ReadOptions=} opt_options Options.
* @protected * @protected
* @return {ol.geom.Geometry} Geometry. * @return {ol.geom.Geometry} Geometry.
*/ */
ol.format.XMLFeature.prototype.readGeometryFromDocument = function(doc, opt_options) {}; ol.format.XMLFeature.prototype.readGeometryFromDocument = function(doc, opt_options) {
throw new Error('Not implemented');
};
/** /**
* @abstract
* @param {Node} node Node. * @param {Node} node Node.
* @param {olx.format.ReadOptions=} opt_options Options. * @param {olx.format.ReadOptions=} opt_options Options.
* @protected * @protected
* @return {ol.geom.Geometry} Geometry. * @return {ol.geom.Geometry} Geometry.
*/ */
ol.format.XMLFeature.prototype.readGeometryFromNode = function(node, opt_options) {}; ol.format.XMLFeature.prototype.readGeometryFromNode = function(node, opt_options) {
throw new Error('Not implemented');
};
/** /**
@@ -214,13 +220,14 @@ ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
/** /**
* @abstract
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
* @param {olx.format.WriteOptions=} opt_options Options. * @param {olx.format.WriteOptions=} opt_options Options.
* @protected * @protected
* @return {Node} Node. * @return {Node} Node.
*/ */
ol.format.XMLFeature.prototype.writeFeatureNode = function(feature, opt_options) {}; ol.format.XMLFeature.prototype.writeFeatureNode = function(feature, opt_options) {
throw new Error('Not implemented');
};
/** /**
@@ -233,12 +240,13 @@ ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) {
/** /**
* @abstract
* @param {Array.<ol.Feature>} features Features. * @param {Array.<ol.Feature>} features Features.
* @param {olx.format.WriteOptions=} opt_options Options. * @param {olx.format.WriteOptions=} opt_options Options.
* @return {Node} Node. * @return {Node} Node.
*/ */
ol.format.XMLFeature.prototype.writeFeaturesNode = function(features, opt_options) {}; ol.format.XMLFeature.prototype.writeFeaturesNode = function(features, opt_options) {
throw new Error('Not implemented');
};
/** /**
@@ -251,9 +259,10 @@ ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
/** /**
* @abstract
* @param {ol.geom.Geometry} geometry Geometry. * @param {ol.geom.Geometry} geometry Geometry.
* @param {olx.format.WriteOptions=} opt_options Options. * @param {olx.format.WriteOptions=} opt_options Options.
* @return {Node} Node. * @return {Node} Node.
*/ */
ol.format.XMLFeature.prototype.writeGeometryNode = function(geometry, opt_options) {}; ol.format.XMLFeature.prototype.writeGeometryNode = function(geometry, opt_options) {
throw new Error('Not implemented');
};
+8
View File
@@ -101,11 +101,19 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
var view = map.getView(); var view = map.getView();
projection = view.getProjection(); projection = view.getProjection();
} }
var formatConstructors = this.formatConstructors_; var formatConstructors = this.formatConstructors_;
var features = []; var features = [];
var i, ii; var i, ii;
for (i = 0, ii = formatConstructors.length; i < ii; ++i) { for (i = 0, ii = formatConstructors.length; i < ii; ++i) {
/**
* Avoid "cannot instantiate abstract class" error.
* @type {Function}
*/
var formatConstructor = formatConstructors[i]; var formatConstructor = formatConstructors[i];
/**
* @type {ol.format.Feature}
*/
var format = new formatConstructor(); var format = new formatConstructor();
features = this.tryReadFeatures_(format, result, { features = this.tryReadFeatures_(format, result, {
featureProjection: projection featureProjection: projection
+1 -1
View File
@@ -331,7 +331,7 @@ ol.Map = function(options) {
* @type {ol.renderer.Map} * @type {ol.renderer.Map}
* @private * @private
*/ */
this.renderer_ = new optionsInternal.rendererConstructor(this.viewport_, this); this.renderer_ = new /** @type {Function} */ (optionsInternal.rendererConstructor)(this.viewport_, this);
/** /**
* @type {function(Event)|undefined} * @type {function(Event)|undefined}
+3
View File
@@ -109,6 +109,9 @@ if (ol.ENABLE_WEBGL) {
} }
var replay = replays[replayType]; var replay = replays[replayType];
if (replay === undefined) { if (replay === undefined) {
/**
* @type {Function}
*/
var Constructor = ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_[replayType]; var Constructor = ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_[replayType];
replay = new Constructor(this.tolerance_, this.maxExtent_); replay = new Constructor(this.tolerance_, this.maxExtent_);
replays[replayType] = replay; replays[replayType] = replay;
+8
View File
@@ -485,6 +485,14 @@ ol.source.Raster.Event = function(type, frameState, data) {
ol.inherits(ol.source.Raster.Event, ol.events.Event); ol.inherits(ol.source.Raster.Event, ol.events.Event);
/**
* @override
*/
ol.source.Raster.prototype.getImageInternal = function() {
throw new Error('Not implemented');
};
/** /**
* @enum {string} * @enum {string}
* @private * @private