GitHub PullRequestReviewCommentEvent at 2014-02-25 15:09:00
Repository: ol3
Actor: ahocevar
Payload: {"comment":{"url":"https://api.github.com/repos/openlayers/ol3/pulls/comments/10038704","id":10038704,"diff_hunk":"@@ -0,0 +1,994 @@\n+goog.provide('ol.format.GML');\n+\n+goog.require('goog.array');\n+goog.require('goog.asserts');\n+goog.require('goog.dom');\n+goog.require('goog.dom.NodeType');\n+goog.require('goog.object');\n+goog.require('goog.string');\n+goog.require('ol.Feature');\n+goog.require('ol.extent');\n+goog.require('ol.format.XML');\n+goog.require('ol.geom.LineString');\n+goog.require('ol.geom.MultiLineString');\n+goog.require('ol.geom.MultiPoint');\n+goog.require('ol.geom.MultiPolygon');\n+goog.require('ol.geom.Point');\n+goog.require('ol.geom.Polygon');\n+goog.require('ol.proj');\n+goog.require('ol.xml');\n+\n+\n+\n+/**\n+ * @constructor\n+ * @param {olx.format.GMLOptions=} opt_options\n+ *     Optional configuration object.\n+ * @extends {ol.format.XML}\n+ * @todo stability experimental\n+ */\n+ol.format.GML = function(opt_options) {\n+  var options = /** @type {olx.format.GMLOptions} */\n+      (goog.isDef(opt_options) ? opt_options : {});\n+\n+  /**\n+   * @private\n+   * @type {string}\n+   */\n+  this.featureType_ = options.featureType;\n+\n+  /**\n+   * @private\n+   * @type {string}\n+   */\n+  this.featureNS_ = options.featureNS;\n+\n+  goog.base(this);\n+};\n+goog.inherits(ol.format.GML, ol.format.XML);\n+\n+\n+/**\n+ * @const\n+ * @private\n+ * @type {Array.<string>}\n+ */\n+ol.format.GML.NAMESPACE_URIS_ = [\n+  'http://www.opengis.net/gml',\n+  'http://www.opengis.net/wfs'\n+];\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @return {Array.<ol.Feature>} Features.\n+ * @private\n+ */\n+ol.format.GML.readFeatures_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  var localName = ol.xml.getLocalName(node);\n+  var context = objectStack[0];\n+  goog.asserts.assert(goog.isObject(context));\n+  var featureType = goog.object.get(context, 'featureType');\n+  var features;\n+  if (localName == 'FeatureCollection') {\n+    features = ol.xml.pushParseAndPop(null,\n+        ol.format.GML.FEATURE_COLLECTION_PARSERS_, node, objectStack);\n+  } else if (localName == 'featureMembers') {\n+    var parsers = {};\n+    var parsersNS = {};\n+    parsers[featureType] = ol.xml.makeArrayPusher(ol.format.GML.readFeature_);\n+    parsersNS[goog.object.get(context, 'featureNS')] = parsers;\n+    features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);\n+  } else {\n+    features = [];\n+  }\n+  return /** @type {Array.<ol.Feature>} */ (features);\n+};\n+\n+\n+/**\n+ * @type {Object.<string, Object.<string, Object>>}\n+ * @private\n+ */\n+ol.format.GML.FEATURE_COLLECTION_PARSERS_ = {\n+  'http://www.opengis.net/gml': {\n+    'featureMembers': ol.xml.makeReplacer(ol.format.GML.readFeatures_)\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @return {ol.geom.Geometry} Geometry.\n+ * @private\n+ */\n+ol.format.GML.readGeometry_ = function(node, objectStack) {\n+  var context = objectStack[0];\n+  goog.asserts.assert(goog.isObject(context));\n+  goog.object.set(context, 'srsName',\n+      node.firstElementChild.getAttribute('srsName'));\n+  return /** @type {ol.geom.Geometry} */ (ol.xml.pushParseAndPop(null,\n+      ol.format.GML.GEOMETRY_PARSERS_, node, objectStack));\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @return {ol.Feature} Feature.\n+ * @private\n+ */\n+ol.format.GML.readFeature_ = function(node, objectStack) {\n+  var n;\n+  var values = {}, geometryName;\n+  for (n = node.firstElementChild; !goog.isNull(n);\n+      n = n.nextElementSibling) {\n+    // Assume attribute elements have one child node and that the child\n+    // is a text node.  Otherwise assume it is a geometry node.\n+    if (n.childNodes.length === 0 ||\n+        (n.childNodes.length === 1 &&\n+        n.firstChild.nodeType === 3)) {\n+      var value = ol.xml.getAllTextContent(n, false);\n+      if (goog.string.isEmpty(value)) {\n+        value = undefined;\n+      }\n+      values[ol.xml.getLocalName(n)] = value;\n+    } else {\n+      geometryName = ol.xml.getLocalName(n);\n+      values[geometryName] = ol.format.GML.readGeometry_(n, objectStack);\n+    }\n+  }\n+  var feature = new ol.Feature(values);\n+  if (goog.isDef(geometryName)) {\n+    feature.setGeometryName(geometryName);\n+  }\n+  return feature;\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.Point|undefined} Point.\n+ */\n+ol.format.GML.readPoint_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'Point');\n+  var flatCoordinates =\n+      ol.format.GML.readFlatCoordinatesFromNode_(node, objectStack);\n+  if (goog.isDefAndNotNull(flatCoordinates)) {\n+    var point = new ol.geom.Point(null);\n+    goog.asserts.assert(flatCoordinates.length == 3);\n+    point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);\n+    return point;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.MultiPoint|undefined} MultiPoint.\n+ */\n+ol.format.GML.readMultiPoint_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'MultiPoint');\n+  var coordinates = ol.xml.pushParseAndPop(\n+      /** @type {Array.<Array.<number>>} */ ([]),\n+      ol.format.GML.MULTIPOINT_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(coordinates)) {\n+    return new ol.geom.MultiPoint(coordinates);\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.MultiLineString|undefined} MultiLineString.\n+ */\n+ol.format.GML.readMultiLineString_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'MultiLineString');\n+  var lineStrings = ol.xml.pushParseAndPop(\n+      /** @type {Array.<ol.geom.LineString>} */ ([]),\n+      ol.format.GML.MULTILINESTRING_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(lineStrings)) {\n+    var multiLineString = new ol.geom.MultiLineString(null);\n+    multiLineString.setLineStrings(lineStrings);\n+    return multiLineString;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.MultiLineString|undefined} MultiLineString.\n+ */\n+ol.format.GML.readMultiCurve_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'MultiCurve');\n+  var lineStrings = ol.xml.pushParseAndPop(\n+      /** @type {Array.<ol.geom.LineString>} */ ([]),\n+      ol.format.GML.MULTICURVE_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(lineStrings)) {\n+    var multiLineString = new ol.geom.MultiLineString(null);\n+    multiLineString.setLineStrings(lineStrings);\n+    return multiLineString;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.MultiPolygon|undefined} MultiPolygon.\n+ */\n+ol.format.GML.readMultiSurface_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'MultiSurface');\n+  var polygons = ol.xml.pushParseAndPop(\n+      /** @type {Array.<ol.geom.Polygon>} */ ([]),\n+      ol.format.GML.MULTISURFACE_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(polygons)) {\n+    var multiPolygon = new ol.geom.MultiPolygon(null);\n+    multiPolygon.setPolygons(polygons);\n+    return multiPolygon;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.MultiPolygon|undefined} MultiPolygon.\n+ */\n+ol.format.GML.readMultiPolygon_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'MultiPolygon');\n+  var polygons = ol.xml.pushParseAndPop(\n+      /** @type {Array.<ol.geom.Polygon>} */ ([]),\n+      ol.format.GML.MULTIPOLYGON_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(polygons)) {\n+    var multiPolygon = new ol.geom.MultiPolygon(null);\n+    multiPolygon.setPolygons(polygons);\n+    return multiPolygon;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.pointMemberParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'pointMember' ||\n+      node.localName == 'pointMembers');\n+  ol.xml.parse(ol.format.GML.POINTMEMBER_PARSERS_, node, objectStack);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.lineStringMemberParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'lineStringMember' ||\n+      node.localName == 'lineStringMembers');\n+  ol.xml.parse(ol.format.GML.LINESTRINGMEMBER_PARSERS_, node, objectStack);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.curveMemberParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'curveMember' ||\n+      node.localName == 'curveMembers');\n+  ol.xml.parse(ol.format.GML.CURVEMEMBER_PARSERS_, node, objectStack);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.surfaceMemberParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'surfaceMember' ||\n+      node.localName == 'surfaceMembers');\n+  ol.xml.parse(ol.format.GML.SURFACEMEMBER_PARSERS_, node, objectStack);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.polygonMemberParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'polygonMember' ||\n+      node.localName == 'polygonMembers');\n+  ol.xml.parse(ol.format.GML.POLYGONMEMBER_PARSERS_, node, objectStack);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.LineString|undefined} LineString.\n+ */\n+ol.format.GML.readLineString_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'LineString');\n+  var flatCoordinates =\n+      ol.format.GML.readFlatCoordinatesFromNode_(node, objectStack);\n+  if (goog.isDefAndNotNull(flatCoordinates)) {\n+    var lineString = new ol.geom.LineString(null);\n+    lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);\n+    return lineString;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<(Array.<number>)>} flat coordinates.\n+ */\n+ol.format.GML.patchesParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'patches');\n+  var result = ol.xml.pushParseAndPop(\n+      /** @type {Array.<Array.<number>>} */ ([null]),\n+      ol.format.GML.PATCHES_PARSERS_, node, objectStack);\n+  if (!goog.isDef(result)) {\n+    return null;\n+  } else {\n+    return result;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>} flat coordinates.\n+ */\n+ol.format.GML.segmentsParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'segments');\n+  var result = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>} */ ([null]),\n+      ol.format.GML.SEGMENTS_PARSERS_, node, objectStack);\n+  if (!goog.isDef(result)) {\n+    return null;\n+  } else {\n+    return result;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<(Array.<number>)>} flat coordinates.\n+ */\n+ol.format.GML.polygonPatchParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'PolygonPatch');\n+  var result = ol.xml.pushParseAndPop(\n+      /** @type {Array.<Array.<number>>} */ ([null]),\n+      ol.format.GML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack);\n+  if (!goog.isDef(result)) {\n+    return null;\n+  } else {\n+    return result;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>} flat coordinates.\n+ */\n+ol.format.GML.lineStringSegmentParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'LineStringSegment');\n+  var result = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>} */ ([null]),\n+      ol.format.GML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack);\n+  if (!goog.isDef(result)) {\n+    return null;\n+  } else {\n+    return result;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.interiorParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'interior');\n+  var flatLinearRing = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>|undefined} */ (undefined),\n+      ol.format.GML.INTERIOR_PARSERS_, node, objectStack);\n+  if (goog.isDef(flatLinearRing)) {\n+    var flatLinearRings = /** @type {Array.<Array.<number>>} */\n+        (objectStack[objectStack.length - 1]);\n+    goog.asserts.assert(goog.isArray(flatLinearRings));\n+    goog.asserts.assert(flatLinearRings.length > 0);\n+    flatLinearRings.push(flatLinearRing);\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ */\n+ol.format.GML.exteriorParser_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'exterior');\n+  var flatLinearRing = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>|undefined} */ (undefined),\n+      ol.format.GML.EXTERIOR_PARSERS_, node, objectStack);\n+  if (goog.isDef(flatLinearRing)) {\n+    var flatLinearRings = /** @type {Array.<Array.<number>>} */\n+        (objectStack[objectStack.length - 1]);\n+    goog.asserts.assert(goog.isArray(flatLinearRings));\n+    goog.asserts.assert(flatLinearRings.length > 0);\n+    flatLinearRings[0] = flatLinearRing;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>} LinearRing flat coordinates.\n+ */\n+ol.format.GML.readFlatLinearRing_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'LinearRing');\n+  return /** @type {Array.<number>} */ (ol.xml.pushParseAndPop(\n+      null, ol.format.GML.FLAT_LINEAR_RING_PARSERS_, node, objectStack));\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.Polygon|undefined} Polygon.\n+ */\n+ol.format.GML.readLinearRing_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'LinearRing');\n+  var flatCoordinates =\n+      ol.format.GML.readFlatCoordinatesFromNode_(node, objectStack);\n+  if (goog.isDef(flatCoordinates)) {\n+    var polygon = new ol.geom.Polygon(null);\n+    polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates,\n+        [flatCoordinates.length]);\n+    return polygon;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.Polygon|undefined} Polygon.\n+ */\n+ol.format.GML.readPolygon_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'Polygon');\n+  var flatLinearRings = ol.xml.pushParseAndPop(\n+      /** @type {Array.<Array.<number>>} */ ([null]),\n+      ol.format.GML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(flatLinearRings) &&\n+      !goog.isNull(flatLinearRings[0])) {\n+    var polygon = new ol.geom.Polygon(null);\n+    var flatCoordinates = flatLinearRings[0];\n+    var ends = [flatCoordinates.length];\n+    var i, ii;\n+    for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {\n+      goog.array.extend(flatCoordinates, flatLinearRings[i]);\n+      ends.push(flatCoordinates.length);\n+    }\n+    polygon.setFlatCoordinates(\n+        ol.geom.GeometryLayout.XYZ, flatCoordinates, ends);\n+    return polygon;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.Polygon|undefined} Polygon.\n+ */\n+ol.format.GML.readSurface_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'Surface');\n+  var flatLinearRings = ol.xml.pushParseAndPop(\n+      /** @type {Array.<Array.<number>>} */ ([null]),\n+      ol.format.GML.SURFACE_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(flatLinearRings) &&\n+      !goog.isNull(flatLinearRings[0])) {\n+    var polygon = new ol.geom.Polygon(null);\n+    var flatCoordinates = flatLinearRings[0];\n+    var ends = [flatCoordinates.length];\n+    var i, ii;\n+    for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {\n+      goog.array.extend(flatCoordinates, flatLinearRings[i]);\n+      ends.push(flatCoordinates.length);\n+    }\n+    polygon.setFlatCoordinates(\n+        ol.geom.GeometryLayout.XYZ, flatCoordinates, ends);\n+    return polygon;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.geom.LineString|undefined} LineString.\n+ */\n+ol.format.GML.readCurve_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'Curve');\n+  var flatCoordinates = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>} */ ([null]),\n+      ol.format.GML.CURVE_PARSERS_, node, objectStack);\n+  if (goog.isDefAndNotNull(flatCoordinates)) {\n+    var lineString = new ol.geom.LineString(null);\n+    lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);\n+    return lineString;\n+  } else {\n+    return undefined;\n+  }\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {ol.Extent|undefined} Envelope.\n+ */\n+ol.format.GML.readEnvelope_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  goog.asserts.assert(node.localName == 'Envelope');\n+  var flatCoordinates = ol.xml.pushParseAndPop(\n+      /** @type {Array.<number>} */ ([null]),\n+      ol.format.GML.ENVELOPE_PARSERS_, node, objectStack);\n+  return ol.extent.createOrUpdate(flatCoordinates[1][0],\n+      flatCoordinates[1][1], flatCoordinates[2][0],\n+      flatCoordinates[2][1]);\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>} Flat coordinates.\n+ */\n+ol.format.GML.readFlatCoordinatesFromNode_ = function(node, objectStack) {\n+  goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);\n+  return /** @type {Array.<number>} */ (ol.xml.pushParseAndPop(\n+      null,\n+      ol.format.GML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack));\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>|undefined} Flat coordinates.\n+ */\n+ol.format.GML.readFlatPos_ = function(node, objectStack) {\n+  var s = ol.xml.getAllTextContent(node, false).replace(/^\\s*|\\s*$/g, '');\n+  var flatCoordinates = goog.array.map(s.split(/\\s+/), parseFloat);\n+  var context = objectStack[0];\n+  goog.asserts.assert(goog.isObject(context));\n+  var containerSrs = goog.object.get(context, 'srsName');\n+  var axisOrientation = 'enu';\n+  if (containerSrs !== null) {\n+    var proj = ol.proj.get(containerSrs);\n+    axisOrientation = proj.getAxisOrientation();\n+  }\n+  if (axisOrientation === 'neu') {\n+    flatCoordinates = flatCoordinates.reverse();\n+  }\n+  var len = flatCoordinates.length;\n+  if (len == 2) {\n+    flatCoordinates.push(0);\n+  }\n+  if (len === 0) {\n+    return undefined;\n+  }\n+  return flatCoordinates;\n+};\n+\n+\n+/**\n+ * @param {Node} node Node.\n+ * @param {Array.<*>} objectStack Object stack.\n+ * @private\n+ * @return {Array.<number>|undefined} Flat coordinates.\n+ */\n+ol.format.GML.readFlatPosList_ = function(node, objectStack) {\n+  var s = ol.xml.getAllTextContent(node, false).replace(/^\\s*|\\s*$/g, '');\n+  var context = objectStack[0];\n+  goog.asserts.assert(goog.isObject(context));\n+  var containerSrs = goog.object.get(context, 'srsName');\n+  var containerDimension = node.parentNode.getAttribute('srsDimension');\n+  var axisOrientation = 'enu';\n+  if (containerSrs !== null) {\n+    var proj = ol.proj.get(containerSrs);\n+    axisOrientation = proj.getAxisOrientation();\n+  }\n+  var coords = s.split(/\\s+/);\n+  // The \"dimension\" attribute is from the GML 3.0.1 spec.\n+  var dim = parseInt(node.getAttribute('srsDimension') ||\n+      node.getAttribute('dimension'), 10) ||\n+      (containerDimension !== null) ?\n+      parseInt(containerDimension, 10) : 2;\n+  var x, y, z;\n+  var flatCoordinates = [];\n+  for (var i = 0, ii = coords.length; i < ii; i += dim) {\n+    x = parseFloat(coords[i]);\n+    y = parseFloat(coords[i + 1]);\n+    z = (dim === 3) ? parseFloat(coords[i + 2]) : 0;\n+    if (axisOrientation === 'enu') {\n+      flatCoordinates.push(x, y, z);\n+    } else {\n+      flatCoordinates.push(y, x, z);\n+    }\n+  }\n+  return flatCoordinates;\n+};\n+\n+\n+/**\n+ * @const\n+ * @type {Object.<string, Object.<string, ol.xml.Parser>>}\n+ * @private\n+ */\n+ol.format.GML.GEOMETRY_PARSERS_ = ol.xml.makeParsersNS(\n+    ol.format.GML.NAMESPACE_URIS_, {","path":"src/ol/format/gmlformat.js","position":718,"original_position":718,"commit_id":"98368a554daed71f67055afe5f9c368e7d8f55f3","original_commit_id":"98368a554daed71f67055afe5f9c368e7d8f55f3","user":{"login":"ahocevar","id":211514,"avatar_url":"https://gravatar.com/avatar/ef092b9a4bdf031eaa9b1eafbb3cb627?d=https%3A%2F%2Fidenticons.github.com%2F175237de411ea5dcbd06d56d5c0c3c49.png&r=x","gravatar_id":"ef092b9a4bdf031eaa9b1eafbb3cb627","url":"https://api.github.com/users/ahocevar","html_url":"https://github.com/ahocevar","followers_url":"https://api.github.com/users/ahocevar/followers","following_url":"https://api.github.com/users/ahocevar/following{/other_user}","gists_url":"https://api.github.com/users/ahocevar/gists{/gist_id}","starred_url":"https://api.github.com/users/ahocevar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahocevar/subscriptions","organizations_url":"https://api.github.com/users/ahocevar/orgs","repos_url":"https://api.github.com/users/ahocevar/repos","events_url":"https://api.github.com/users/ahocevar/events{/privacy}","received_events_url":"https://api.github.com/users/ahocevar/received_events","type":"User","site_admin":false},"body":"Can these nodes also have a wfs namespace, or just gml? If the latter, I'd not use `ol.xml.makeParsersNS()`. The same question applies to more parser lookup structures below.","created_at":"2014-02-25T15:09:00Z","updated_at":"2014-02-25T15:09:00Z","html_url":"https://github.com/openlayers/ol3/pull/1752#discussion_r10038704","pull_request_url":"https://api.github.com/repos/openlayers/ol3/pulls/1752","_links":{"self":{"href":"https://api.github.com/repos/openlayers/ol3/pulls/comments/10038704"},"html":{"href":"https://github.com/openlayers/ol3/pull/1752#discussion_r10038704"},"pull_request":{"href":"https://api.github.com/repos/openlayers/ol3/pulls/1752"}}}}