diff --git a/src/ol/format/gmlformat.js b/src/ol/format/gmlformat.js
index dfde2a18c7..94236f93af 100644
--- a/src/ol/format/gmlformat.js
+++ b/src/ol/format/gmlformat.js
@@ -159,6 +159,28 @@ ol.format.GML.readMultiCurve_ = function(node, objectStack) {
};
+/**
+ * @param {Node} node Node.
+ * @param {Array.<*>} objectStack Object stack.
+ * @private
+ * @return {ol.geom.MultiPolygon|undefined} MultiPolygon.
+ */
+ol.format.GML.readMultiSurface_ = function(node, objectStack) {
+ goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
+ goog.asserts.assert(node.localName == 'MultiSurface');
+ var polygons = ol.xml.pushParseAndPop(
+ /** @type {Array.
} */ ([]),
+ ol.format.GML.MULTISURFACE_PARSERS_, node, objectStack);
+ if (goog.isDefAndNotNull(polygons)) {
+ var multiPolygon = new ol.geom.MultiPolygon(null);
+ multiPolygon.setPolygons(polygons);
+ return multiPolygon;
+ } else {
+ return undefined;
+ }
+};
+
+
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -220,6 +242,19 @@ ol.format.GML.curveMemberParser_ = function(node, objectStack) {
};
+/**
+ * @param {Node} node Node.
+ * @param {Array.<*>} objectStack Object stack.
+ * @private
+ */
+ol.format.GML.surfaceMemberParser_ = function(node, objectStack) {
+ goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
+ goog.asserts.assert(node.localName == 'surfaceMember' ||
+ node.localName == 'surfaceMembers');
+ ol.xml.parse(ol.format.GML.SURFACEMEMBER_PARSERS_, node, objectStack);
+};
+
+
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -592,6 +627,7 @@ ol.format.GML.GEOMETRY_PARSERS_ = ol.xml.makeParsersNS(
'Polygon': ol.xml.makeArrayPusher(ol.format.GML.readPolygon_),
'MultiPolygon': ol.xml.makeArrayPusher(ol.format.GML.readMultiPolygon_),
'Surface': ol.xml.makeArrayPusher(ol.format.GML.readSurface_),
+ 'MultiSurface': ol.xml.makeArrayPusher(ol.format.GML.readMultiSurface_),
'Curve': ol.xml.makeArrayPusher(ol.format.GML.readCurve_),
'MultiCurve': ol.xml.makeArrayPusher(ol.format.GML.readMultiCurve_),
'Envelope': ol.xml.makeArrayPusher(ol.format.GML.readEnvelope_)
@@ -662,6 +698,20 @@ ol.format.GML.MULTICURVE_PARSERS_ = ol.xml.makeParsersNS(
});
+/**
+ * @const
+ * @type {Object.>}
+ * @private
+ */
+ol.format.GML.MULTISURFACE_PARSERS_ = ol.xml.makeParsersNS(
+ ol.format.GML.NAMESPACE_URIS_, {
+ 'surfaceMember': ol.xml.makeArrayPusher(
+ ol.format.GML.surfaceMemberParser_),
+ 'surfaceMembers': ol.xml.makeArrayPusher(
+ ol.format.GML.surfaceMemberParser_)
+ });
+
+
/**
* @const
* @type {Object.>}
@@ -712,6 +762,18 @@ ol.format.GML.CURVEMEMBER_PARSERS_ = ol.xml.makeParsersNS(
});
+/**
+ * @const
+ * @type {Object.>}
+ * @private
+ */
+ol.format.GML.SURFACEMEMBER_PARSERS_ = ol.xml.makeParsersNS(
+ ol.format.GML.NAMESPACE_URIS_, {
+ 'Polygon': ol.xml.makeArrayPusher(ol.format.GML.readPolygon_),
+ 'Surface': ol.xml.makeArrayPusher(ol.format.GML.readSurface_)
+ });
+
+
/**
* @const
* @type {Object.>}
diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js
index 8a9889535f..75d090cbde 100644
--- a/test/spec/ol/format/gmlformat.test.js
+++ b/test/spec/ol/format/gmlformat.test.js
@@ -387,6 +387,144 @@ describe('ol.format.GML', function() {
});
+ describe('multisurface', function() {
+
+ it('can read a singular multisurface geometry', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 2 3 2 5 4 5 2 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3 4 3 6 5 6 3 4' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var g = format.readGeometry(text);
+ expect(g).to.be.an(ol.geom.MultiPolygon);
+ expect(g.getCoordinates()).to.eql([
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0],
+ [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
+ [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
+ });
+
+ it('can read a plural multisurface geometry', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 2 3 2 5 4 5 2 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3 4 3 6 5 6 3 4' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var g = format.readGeometry(text);
+ expect(g).to.be.an(ol.geom.MultiPolygon);
+ expect(g.getCoordinates()).to.eql([
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0],
+ [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
+ [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
+ });
+
+ it('can read a multisurface-surface geometry', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 2 3 2 5 4 5 2 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3 4 3 6 5 6 3 4' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 1 2 3 2 3 4 1 2' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var g = format.readGeometry(text);
+ expect(g).to.be.an(ol.geom.MultiPolygon);
+ expect(g.getCoordinates()).to.eql([
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0],
+ [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]],
+ [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]],
+ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]);
+ });
+
+ });
+
});
});