From a8bd0c5dd7a24547ac5fd8c1e41ea680f98181e2 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 17 Jul 2018 16:59:13 +0200 Subject: [PATCH] Use extends and super for format/KML --- src/ol/format/KML.js | 68 ++++++-------------------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index be5b75b5dd..e45e3b6afa 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -1,7 +1,6 @@ /** * @module ol/format/KML */ -import {inherits} from '../util.js'; import Feature from '../Feature.js'; import {extend, includes} from '../array.js'; import {assert} from '../asserts.js'; @@ -388,23 +387,28 @@ function createStyleDefaults() { * @classdesc * Feature format for reading and writing data in the KML format. * + * {@link module:ol/format/KML~KML#readFeature} will read the first feature from + * a KML source. + * + * MultiGeometries are converted into GeometryCollections if they are a mix of + * geometry types, and into MultiPoint/MultiLineString/MultiPolygon if they are + * all of the same type. + * * Note that the KML format uses the URL() constructor. Older browsers such as IE * which do not support this will need a URL polyfill to be loaded before use. * - * @extends {module:ol/format/XMLFeature} * @api */ -class KML { +class KML extends XMLFeature { /** * @param {module:ol/format/KML~Options=} opt_options Options. */ constructor(opt_options) { + super(); const options = opt_options ? opt_options : {}; - XMLFeature.call(this); - if (!DEFAULT_STYLE_ARRAY) { createStyleDefaults(); } @@ -849,8 +853,6 @@ class KML { } } -inherits(KML, XMLFeature); - /** * @param {module:ol/style/Style|undefined} foundStyle Style. @@ -2066,45 +2068,6 @@ function whenParser(node, objectStack) { } -/** - * Read the first feature from a KML source. MultiGeometries are converted into - * GeometryCollections if they are a mix of geometry types, and into MultiPoint/ - * MultiLineString/MultiPolygon if they are all of the same type. - * - * @function - * @param {Document|Node|Object|string} source Source. - * @param {module:ol/format/Feature~ReadOptions=} opt_options Read options. - * @return {module:ol/Feature} Feature. - * @api - */ -KML.prototype.readFeature; - - -/** - * Read all features from a KML source. MultiGeometries are converted into - * GeometryCollections if they are a mix of geometry types, and into MultiPoint/ - * MultiLineString/MultiPolygon if they are all of the same type. - * - * @function - * @param {Document|Node|Object|string} source Source. - * @param {module:ol/format/Feature~ReadOptions=} opt_options Read options. - * @return {Array.} Features. - * @api - */ -KML.prototype.readFeatures; - - -/** - * Read the projection from a KML source. - * - * @function - * @param {Document|Node|Object|string} source Source. - * @return {module:ol/proj/Projection} Projection. - * @api - */ -KML.prototype.readProjection; - - /** * @param {Node} node Node to append a TextNode with the color to. * @param {module:ol/color~Color|string} color Color. @@ -2964,17 +2927,4 @@ function writeVec2(node, vec2) { } -/** - * Encode an array of features in the KML format. GeometryCollections, MultiPoints, - * MultiLineStrings, and MultiPolygons are output as MultiGeometries. - * - * @function - * @param {Array.} features Features. - * @param {module:ol/format/Feature~WriteOptions=} opt_options Options. - * @return {string} Result. - * @api - */ -KML.prototype.writeFeatures; - - export default KML;