Use extends and super for format/Polyline
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/format/Polyline
|
* @module ol/format/Polyline
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../util.js';
|
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import Feature from '../Feature.js';
|
import Feature from '../Feature.js';
|
||||||
import {transformWithOptions} from '../format/Feature.js';
|
import {transformWithOptions} from '../format/Feature.js';
|
||||||
@@ -27,19 +26,25 @@ import {get as getProjection} from '../proj.js';
|
|||||||
* Feature format for reading and writing data in the Encoded
|
* Feature format for reading and writing data in the Encoded
|
||||||
* Polyline Algorithm Format.
|
* Polyline Algorithm Format.
|
||||||
*
|
*
|
||||||
* @extends {module:ol/format/TextFeature}
|
* When reading features, the coordinates are assumed to be in two dimensions
|
||||||
|
* and in [latitude, longitude] order.
|
||||||
|
*
|
||||||
|
* As Polyline sources contain a single feature,
|
||||||
|
* {@link module:ol/format/Polyline~Polyline#readFeatures} will return the
|
||||||
|
* feature in an array.
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Polyline {
|
class Polyline extends TextFeature {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/format/Polyline~Options=} opt_options Optional configuration object.
|
* @param {module:ol/format/Polyline~Options=} opt_options Optional configuration object.
|
||||||
*/
|
*/
|
||||||
constructor(opt_options) {
|
constructor(opt_options) {
|
||||||
|
super();
|
||||||
|
|
||||||
const options = opt_options ? opt_options : {};
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
TextFeature.call(this);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
@@ -127,8 +132,6 @@ class Polyline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(Polyline, TextFeature);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode a list of n-dimensional points and return an encoded string
|
* Encode a list of n-dimensional points and return an encoded string
|
||||||
@@ -334,65 +337,4 @@ export function encodeUnsignedInteger(num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the feature from the Polyline source. The coordinates are assumed to be
|
|
||||||
* in two dimensions and in latitude, longitude order.
|
|
||||||
*
|
|
||||||
* @function
|
|
||||||
* @param {Document|Node|Object|string} source Source.
|
|
||||||
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
|
||||||
* @return {module:ol/Feature} Feature.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
Polyline.prototype.readFeature;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the feature from the source. As Polyline sources contain a single
|
|
||||||
* feature, this will return the feature in an array.
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
Polyline.prototype.readFeatures;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the geometry from the 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
|
|
||||||
*/
|
|
||||||
Polyline.prototype.readGeometry;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the projection from a Polyline source.
|
|
||||||
*
|
|
||||||
* @function
|
|
||||||
* @param {Document|Node|Object|string} source Source.
|
|
||||||
* @return {module:ol/proj/Projection} Projection.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
Polyline.prototype.readProjection;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write a single geometry in Polyline format.
|
|
||||||
*
|
|
||||||
* @function
|
|
||||||
* @param {module:ol/geom/Geometry} geometry Geometry.
|
|
||||||
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
|
||||||
* @return {string} Geometry.
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
Polyline.prototype.writeGeometry;
|
|
||||||
|
|
||||||
|
|
||||||
export default Polyline;
|
export default Polyline;
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ class TextFeature {
|
|||||||
readFeaturesFromText(text, opt_options) {}
|
readFeaturesFromText(text, opt_options) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* Read the geometry from the source.
|
||||||
|
*
|
||||||
|
* @param {Document|Node|Object|string} source Source.
|
||||||
|
* @param {module:ol/format/Feature~ReadOptions=} opt_options Read options.
|
||||||
|
* @return {module:ol/geom/Geometry} Geometry.
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
readGeometry(source, opt_options) {
|
readGeometry(source, opt_options) {
|
||||||
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
|
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
|
||||||
@@ -138,7 +143,13 @@ class TextFeature {
|
|||||||
writeFeaturesText(features, opt_options) {}
|
writeFeaturesText(features, opt_options) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* Write a single geometry in Polyline format.
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {module:ol/geom/Geometry} geometry Geometry.
|
||||||
|
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
|
||||||
|
* @return {string} Geometry.
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
writeGeometry(geometry, opt_options) {
|
writeGeometry(geometry, opt_options) {
|
||||||
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
||||||
|
|||||||
Reference in New Issue
Block a user