Use extends and super for format/WKT

This commit is contained in:
ahocevar
2018-07-17 17:56:30 +02:00
parent 942a219c30
commit df89b0718a
2 changed files with 16 additions and 81 deletions

View File

@@ -109,7 +109,13 @@ class TextFeature extends FeatureFormat {
} }
/** /**
* @inheritDoc * Encode a feature as a string.
*
* @function
* @param {module:ol/Feature} feature Feature.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Encoded feature.
* @api
*/ */
writeFeature(feature, opt_options) { writeFeature(feature, opt_options) {
return this.writeFeatureText(feature, this.adaptOptions(opt_options)); return this.writeFeatureText(feature, this.adaptOptions(opt_options));
@@ -125,7 +131,12 @@ class TextFeature extends FeatureFormat {
writeFeatureText(feature, opt_options) {} writeFeatureText(feature, opt_options) {}
/** /**
* @inheritDoc * Encode an array of features as string.
*
* @param {Array.<module:ol/Feature>} features Features.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Encoded features.
* @api
*/ */
writeFeatures(features, opt_options) { writeFeatures(features, opt_options) {
return this.writeFeaturesText(features, this.adaptOptions(opt_options)); return this.writeFeaturesText(features, this.adaptOptions(opt_options));
@@ -141,7 +152,7 @@ class TextFeature extends FeatureFormat {
writeFeaturesText(features, opt_options) {} writeFeaturesText(features, opt_options) {}
/** /**
* Write a single geometry in Polyline format. * Write a single geometry.
* *
* @function * @function
* @param {module:ol/geom/Geometry} geometry Geometry. * @param {module:ol/geom/Geometry} geometry Geometry.

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/format/WKT * @module ol/format/WKT
*/ */
import {inherits} from '../util.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import {transformWithOptions} from '../format/Feature.js'; import {transformWithOptions} from '../format/Feature.js';
import TextFeature from '../format/TextFeature.js'; import TextFeature from '../format/TextFeature.js';
@@ -594,19 +593,18 @@ class Parser {
* Geometry format for reading and writing data in the `WellKnownText` (WKT) * Geometry format for reading and writing data in the `WellKnownText` (WKT)
* format. * format.
* *
* @extends {module:ol/format/TextFeature}
* @api * @api
*/ */
class WKT { class WKT extends TextFeature {
/** /**
* @param {module:ol/format/WKT~Options=} opt_options Options. * @param {module:ol/format/WKT~Options=} opt_options Options.
*/ */
constructor(opt_options) { constructor(opt_options) {
super();
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
TextFeature.call(this);
/** /**
* Split GeometryCollection into multiple features. * Split GeometryCollection into multiple features.
@@ -715,8 +713,6 @@ class WKT {
} }
} }
inherits(WKT, TextFeature);
/** /**
* @param {module:ol/geom/Point} geom Point geometry. * @param {module:ol/geom/Point} geom Point geometry.
@@ -869,76 +865,4 @@ function encode(geom) {
} }
/**
* Read a feature from a WKT source.
*
* @function
* @param {Document|Node|Object|string} source Source.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {module:ol/Feature} Feature.
* @api
*/
WKT.prototype.readFeature;
/**
* Read all features from a WKT source.
*
* @function
* @param {Document|Node|Object|string} source Source.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {Array.<module:ol/Feature>} Features.
* @api
*/
WKT.prototype.readFeatures;
/**
* Read a single geometry from a WKT source.
*
* @function
* @param {Document|Node|Object|string} source Source.
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
* @return {module:ol/geom/Geometry} Geometry.
* @api
*/
WKT.prototype.readGeometry;
/**
* Encode a feature as a WKT string.
*
* @function
* @param {module:ol/Feature} feature Feature.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} WKT string.
* @api
*/
WKT.prototype.writeFeature;
/**
* Encode an array of features as a WKT string.
*
* @function
* @param {Array.<module:ol/Feature>} features Features.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} WKT string.
* @api
*/
WKT.prototype.writeFeatures;
/**
* Write a single geometry as a WKT string.
*
* @function
* @param {module:ol/geom/Geometry} geometry Geometry.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} WKT string.
* @api
*/
WKT.prototype.writeGeometry;
export default WKT; export default WKT;