diff --git a/src/ol/format/GML2.js b/src/ol/format/GML2.js index 313bf83535..d4aa83dffa 100644 --- a/src/ol/format/GML2.js +++ b/src/ol/format/GML2.js @@ -179,7 +179,7 @@ class GML2 extends GMLBase { writeFeatureElement(node, feature, objectStack) { const fid = feature.getId(); if (fid) { - node.setAttribute('fid', fid); + node.setAttribute('fid', /** @type {string} */ (fid)); } const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const featureNS = context['featureNS']; @@ -285,7 +285,7 @@ class GML2 extends GMLBase { writeGeometryElement(node, geometry, objectStack) { const context = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[objectStack.length - 1]); const item = assign({}, context); - item.node = node; + item['node'] = node; let value; if (Array.isArray(geometry)) { if (context.dataProjection) { @@ -588,9 +588,9 @@ class GML2 extends GMLBase { /** * @const * @type {Object>} - * @private + * @protected */ -GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { 'http://www.opengis.net/gml': { 'coordinates': makeReplacer(GML2.prototype.readFlatCoordinates_) } @@ -599,9 +599,9 @@ GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { /** * @const * @type {Object>} - * @private + * @protected */ -GML2.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { +GML2.prototype.FLAT_LINEAR_RINGS_PARSERS = { 'http://www.opengis.net/gml': { 'innerBoundaryIs': GML2.prototype.innerBoundaryIsParser_, 'outerBoundaryIs': GML2.prototype.outerBoundaryIsParser_ @@ -623,9 +623,9 @@ GML2.prototype.BOX_PARSERS_ = { /** * @const * @type {Object>} - * @private + * @protected */ -GML2.prototype.GEOMETRY_PARSERS_ = { +GML2.prototype.GEOMETRY_PARSERS = { 'http://www.opengis.net/gml': { 'Point': makeReplacer(GMLBase.prototype.readPoint), 'MultiPoint': makeReplacer( diff --git a/src/ol/format/GML3.js b/src/ol/format/GML3.js index 276d7b2e73..66ccca3a18 100644 --- a/src/ol/format/GML3.js +++ b/src/ol/format/GML3.js @@ -183,7 +183,7 @@ class GML3 extends GMLBase { */ readPolygonPatch_(node, objectStack) { return pushParseAndPop([null], - this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); + this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this); } /** @@ -194,7 +194,7 @@ class GML3 extends GMLBase { */ readLineStringSegment_(node, objectStack) { return pushParseAndPop([null], - this.GEOMETRY_FLAT_COORDINATES_PARSERS_, + this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this); } @@ -357,9 +357,9 @@ class GML3 extends GMLBase { } else if (node.getAttribute('dimension')) { dim = readNonNegativeIntegerString( node.getAttribute('dimension')); - } else if (node.parentNode.getAttribute('srsDimension')) { + } else if (/** @type {Element} */ (node.parentNode).getAttribute('srsDimension')) { dim = readNonNegativeIntegerString( - node.parentNode.getAttribute('srsDimension')); + /** @type {Element} */ (node.parentNode).getAttribute('srsDimension')); } else if (contextDimension) { dim = readNonNegativeIntegerString(contextDimension); } @@ -387,7 +387,7 @@ class GML3 extends GMLBase { writePos_(node, value, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context['hasZ']; - const srsDimension = hasZ ? 3 : 2; + const srsDimension = hasZ ? '3' : '2'; node.setAttribute('srsDimension', srsDimension); const srsName = context['srsName']; let axisOrientation = 'enu'; @@ -443,7 +443,7 @@ class GML3 extends GMLBase { writePosList_(node, value, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context['hasZ']; - const srsDimension = hasZ ? 3 : 2; + const srsDimension = hasZ ? '3' : '2'; node.setAttribute('srsDimension', srsDimension); const srsName = context['srsName']; // only 2d for simple features profile @@ -731,7 +731,7 @@ class GML3 extends GMLBase { writeGeometryElement(node, geometry, objectStack) { const context = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[objectStack.length - 1]); const item = assign({}, context); - item.node = node; + item['node'] = node; let value; if (Array.isArray(geometry)) { if (context.dataProjection) { @@ -757,7 +757,7 @@ class GML3 extends GMLBase { writeFeatureElement(node, feature, objectStack) { const fid = feature.getId(); if (fid) { - node.setAttribute('fid', fid); + node.setAttribute('fid', /** @type {string} */ (fid)); } const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const featureNS = context['featureNS']; @@ -805,6 +805,7 @@ class GML3 extends GMLBase { const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const featureType = context['featureType']; const featureNS = context['featureNS']; + /** @type {Object>} */ const serializers = {}; serializers[featureNS] = {}; serializers[featureNS][featureType] = makeChildAppender( @@ -921,9 +922,9 @@ class GML3 extends GMLBase { /** * @const * @type {Object>} - * @private + * @protected */ -GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { 'http://www.opengis.net/gml': { 'pos': makeReplacer(GML3.prototype.readFlatPos_), 'posList': makeReplacer(GML3.prototype.readFlatPosList_) @@ -934,9 +935,9 @@ GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { /** * @const * @type {Object>} - * @private + * @protected */ -GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { +GML3.prototype.FLAT_LINEAR_RINGS_PARSERS = { 'http://www.opengis.net/gml': { 'interior': GML3.prototype.interiorParser_, 'exterior': GML3.prototype.exteriorParser_ @@ -947,9 +948,9 @@ GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { /** * @const * @type {Object>} - * @private + * @protected */ -GML3.prototype.GEOMETRY_PARSERS_ = { +GML3.prototype.GEOMETRY_PARSERS = { 'http://www.opengis.net/gml': { 'Point': makeReplacer(GMLBase.prototype.readPoint), 'MultiPoint': makeReplacer( diff --git a/src/ol/format/GMLBase.js b/src/ol/format/GMLBase.js index f07f0cd9ce..8cab7b8084 100644 --- a/src/ol/format/GMLBase.js +++ b/src/ol/format/GMLBase.js @@ -71,6 +71,7 @@ const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/; * gml:MultiPolygon. Since the latter is deprecated in GML 3. * @property {string} [schemaLocation] Optional schemaLocation to use when * writing out the GML, this will override the default provided. + * @property {boolean} [hasZ=false] If coordinates have a Z value. */ @@ -126,7 +127,6 @@ class GMLBase extends XMLFeature { 'featureMember': makeReplacer(this.readFeaturesInternal), 'featureMembers': makeReplacer(this.readFeaturesInternal) }; - } /** @@ -189,9 +189,11 @@ class GMLBase extends XMLFeature { featureNS = {}; featureNS[defaultPrefix] = ns; } + /** @type {Object>} */ const parsersNS = {}; const featureTypes = Array.isArray(featureType) ? featureType : [featureType]; for (const p in featureNS) { + /** @type {Object} */ const parsers = {}; for (let i = 0, ii = featureTypes.length; i < ii; ++i) { const featurePrefix = featureTypes[i].indexOf(':') === -1 ? @@ -227,7 +229,7 @@ class GMLBase extends XMLFeature { context['srsName'] = node.firstElementChild.getAttribute('srsName'); context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension'); /** @type {import("../geom/Geometry.js").default} */ - const geometry = pushParseAndPop(null, this.GEOMETRY_PARSERS_, node, objectStack, this); + const geometry = pushParseAndPop(null, this.GEOMETRY_PARSERS, node, objectStack, this); if (geometry) { return ( /** @type {import("../geom/Geometry.js").default} */ (transformWithOptions(geometry, false, context)) @@ -383,7 +385,7 @@ class GMLBase extends XMLFeature { */ readFlatLinearRing_(node, objectStack) { const ring = pushParseAndPop(null, - this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, + this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this); if (ring) { return ring; @@ -412,7 +414,7 @@ class GMLBase extends XMLFeature { readPolygon(node, objectStack) { /** @type {Array>} */ const flatLinearRings = pushParseAndPop([null], - this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); + this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this); if (flatLinearRings && flatLinearRings[0]) { const flatCoordinates = flatLinearRings[0]; const ends = [flatCoordinates.length]; @@ -434,7 +436,7 @@ class GMLBase extends XMLFeature { * @return {Array} Flat coordinates. */ readFlatCoordinatesFromNode_(node, objectStack) { - return pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack, this); + return pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this); } /** @@ -469,6 +471,37 @@ class GMLBase extends XMLFeature { } } + +/** + * @const + * @type {Object>} + * @protected + */ +GMLBase.prototype.FLAT_LINEAR_RINGS_PARSERS = { + 'http://www.opengis.net/gml': {} +}; + + +/** + * @const + * @type {Object>} + * @protected + */ +GMLBase.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { + 'http://www.opengis.net/gml': {} +}; + + +/** + * @const + * @type {Object>} + * @protected + */ +GMLBase.prototype.GEOMETRY_PARSERS = { + 'http://www.opengis.net/gml': {} +}; + + /** * @const * @type {Object>} diff --git a/src/ol/geom/MultiLineString.js b/src/ol/geom/MultiLineString.js index 39d4eaf499..33f7273d43 100644 --- a/src/ol/geom/MultiLineString.js +++ b/src/ol/geom/MultiLineString.js @@ -23,7 +23,7 @@ import {douglasPeuckerArray} from '../geom/flat/simplify.js'; class MultiLineString extends SimpleGeometry { /** - * @param {Array|import("../geom.js").MultiLineString>|Array} coordinates + * @param {Array|LineString>|Array} coordinates * Coordinates or LineString geometries. (For internal use, flat coordinates in * combination with `opt_layout` and `opt_ends` are also accepted.) * @param {GeometryLayout=} opt_layout Layout. @@ -58,7 +58,7 @@ class MultiLineString extends SimpleGeometry { this.ends_ = opt_ends; } else { let layout = this.getLayout(); - const lineStrings = /** @type {Array} */ (coordinates); + const lineStrings = /** @type {Array} */ (coordinates); const flatCoordinates = []; const ends = []; for (let i = 0, ii = lineStrings.length; i < ii; ++i) { diff --git a/src/ol/geom/MultiPolygon.js b/src/ol/geom/MultiPolygon.js index 1e582acdae..cc172491af 100644 --- a/src/ol/geom/MultiPolygon.js +++ b/src/ol/geom/MultiPolygon.js @@ -29,7 +29,7 @@ class MultiPolygon extends SimpleGeometry { /** * @param {Array>|Polygon>|Array} coordinates Coordinates. - * For internal use, flat coordinats in combination with `opt_layout` and `opt_endss` are also accepted. + * For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted. * @param {GeometryLayout=} opt_layout Layout. * @param {Array>=} opt_endss Array of ends for internal use with flat coordinates. */