diff --git a/src/ol/format/GMLBase.js b/src/ol/format/GMLBase.js index 595848f70e..926bf8b076 100644 --- a/src/ol/format/GMLBase.js +++ b/src/ol/format/GMLBase.js @@ -238,34 +238,51 @@ class GMLBase extends XMLFeature { * @param {Array<*>} objectStack Object stack. * @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry. */ - readGeometryElement(node, objectStack) { + readGeometryOrExtent(node, objectStack) { const context = /** @type {Object} */ (objectStack[0]); context['srsName'] = node.firstElementChild.getAttribute('srsName'); context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension'); - const geometry = pushParseAndPop( + return pushParseAndPop( null, this.GEOMETRY_PARSERS, node, objectStack, this ); - if (geometry) { - if (Array.isArray(geometry)) { - return transformExtentWithOptions( - /** @type {import("../extent.js").Extent} */ (geometry), + } + + /** + * @param {Element} node Node. + * @param {Array<*>} objectStack Object stack. + * @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry. + */ + readExtentElement(node, objectStack) { + const context = /** @type {Object} */ (objectStack[0]); + const extent = this.readGeometryOrExtent(node, objectStack); + return extent + ? transformExtentWithOptions( + /** @type {import("../extent.js").Extent} */ (extent), context - ); - } else { - return transformGeometryWithOptions( + ) + : undefined; + } + + /** + * @param {Element} node Node. + * @param {Array<*>} objectStack Object stack. + * @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry. + */ + readGeometryElement(node, objectStack) { + const context = /** @type {Object} */ (objectStack[0]); + const geometry = this.readGeometryOrExtent(node, objectStack); + return geometry + ? transformGeometryWithOptions( /** @type {import("../geom/Geometry.js").default} */ (geometry), false, context - ); - } - } else { - return undefined; - } + ) + : undefined; } /** @@ -292,8 +309,11 @@ class GMLBase extends XMLFeature { } } else { if (asFeature) { - //if feature, try it as a geometry - value = this.readGeometryElement(n, objectStack); + //if feature, try it as a geometry or extent + value = + localName === 'boundedBy' + ? this.readExtentElement(n, objectStack) + : this.readGeometryElement(n, objectStack); } if (!value) { //if not a geometry or not a feature, treat it as a complex attribute diff --git a/src/ol/format/WFS.js b/src/ol/format/WFS.js index 99e6266d55..b21f3c7395 100644 --- a/src/ol/format/WFS.js +++ b/src/ol/format/WFS.js @@ -36,7 +36,7 @@ import { const FEATURE_COLLECTION_PARSERS = { 'http://www.opengis.net/gml': { 'boundedBy': makeObjectPropertySetter( - GMLBase.prototype.readGeometryElement, + GMLBase.prototype.readExtentElement, 'bounds' ), },