diff --git a/src/ol/format/gml2.js b/src/ol/format/gml2.js
index dce88074e3..8c1fb481fb 100644
--- a/src/ol/format/gml2.js
+++ b/src/ol/format/gml2.js
@@ -59,7 +59,6 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
var containerSrs = context['srsName'];
- var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu';
if (containerSrs) {
var proj = ol.proj.get(containerSrs);
@@ -67,24 +66,14 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
axisOrientation = proj.getAxisOrientation();
}
}
- var coords = s.split(/[\s,]+/);
- // The "dimension" attribute is from the GML 3.0.1 spec.
- var dim = 2;
- if (node.getAttribute('srsDimension')) {
- dim = ol.format.XSD.readNonNegativeIntegerString(
- node.getAttribute('srsDimension'));
- } else if (node.getAttribute('dimension')) {
- dim = ol.format.XSD.readNonNegativeIntegerString(
- node.getAttribute('dimension'));
- } else if (containerDimension) {
- dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension);
- }
+ var coordsGroups = s.trim().split(/\s+/);
var x, y, z;
var flatCoordinates = [];
- for (var i = 0, ii = coords.length; i < ii; i += dim) {
- x = parseFloat(coords[i]);
- y = parseFloat(coords[i + 1]);
- z = (dim === 3) ? parseFloat(coords[i + 2]) : 0;
+ for (var i = 0, ii = coordsGroups.length; i < ii; i++) {
+ var coords = coordsGroups[i].split(/,+/);
+ x = parseFloat(coords[0]);
+ y = parseFloat(coords[1]);
+ z = (coords.length === 3) ? parseFloat(coords[2]) : 0;
if (axisOrientation.substr(0, 2) === 'en') {
flatCoordinates.push(x, y, z);
} else {
diff --git a/test/spec/ol/format/gml.test.js b/test/spec/ol/format/gml.test.js
index 4010d56ee7..3376e6712f 100644
--- a/test/spec/ol/format/gml.test.js
+++ b/test/spec/ol/format/gml.test.js
@@ -62,6 +62,17 @@ describe('ol.format.GML2', function() {
expect(g.getCoordinates()).to.eql([-180, -90, 0]);
});
+ it('can read a 3D point geometry', function() {
+ var text = '' +
+ ' -90,-180,42' +
+ '';
+
+ var g = readGeometry(format, text);
+ expect(g).to.be.an(ol.geom.Point);
+ expect(g.getCoordinates()).to.eql([-180, -90, 42]);
+ });
+
it('can read a box element', function() {
var text = '' +
@@ -86,17 +97,17 @@ describe('ol.format.GML2', function() {
' -0.768746,47.358268 ' +
' -0.574463,47.684285 -0.347374,47.854602 ' +
' -0.006740,47.925567 ' +
- ' 0.135191,47.726864 0.149384,47.599127 0.419052,' +
- ' 47.670092 0.532597,47.428810 ' +
- ' 0.305508,47.443003 0.475824,47.144948 0.064225,' +
- ' 47.201721 ' +
+ ' 0.135191,47.726864 0.149384,47.599127 ' +
+ ' 0.419052,47.670092 0.532597,47.428810 ' +
+ ' 0.305508,47.443003 0.475824,47.144948 ' +
+ ' 0.064225,47.201721 ' +
' -0.318987,47.003018 ' +
' ' +
' ' +
' ' +
' ' +
- ' -0.035126,47.485582 -0.035126,' +
- ' 47.485582 ' +
+ ' -0.035126,47.485582 ' +
+ ' -0.035126,47.485582 ' +
' -0.049319,47.641706 -0.233829,47.655899 ' +
' -0.375760,47.457196 ' +
' -0.276408,47.286879 -0.035126,47.485582 ' +