diff --git a/src/ol/format/gmlformat.js b/src/ol/format/gmlformat.js index 6ee8620a1e..a4b7cfbaea 100644 --- a/src/ol/format/gmlformat.js +++ b/src/ol/format/gmlformat.js @@ -1,5 +1,3 @@ -//FIXME Implement readProjectionFrom* - goog.provide('ol.format.GML'); goog.require('goog.asserts'); @@ -1077,8 +1075,8 @@ ol.format.GML.prototype.readFeaturesFromNode = function(node, opt_options) { * @inheritDoc */ ol.format.GML.prototype.readProjectionFromNode = function(node) { - //TODO read this from data - return ol.proj.get(this.srsName_); + return goog.isDef(this.srsName_) ? this.srsName_ : + node.firstElementChild.getAttribute('srsName'); }; diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js index fc2e5ffcbe..e96d571ae7 100644 --- a/test/spec/ol/format/gmlformat.test.js +++ b/test/spec/ol/format/gmlformat.test.js @@ -10,10 +10,11 @@ var readGeometry = function(format, text, opt_options) { describe('ol.format.GML', function() { - var format, formatWGS84; + var format, formatWGS84, formatNoSrs; beforeEach(function() { format = new ol.format.GML({srsName: 'CRS:84'}); formatWGS84 = new ol.format.GML({srsName: 'urn:x-ogc:def:crs:EPSG:4326'}); + formatNoSrs = new ol.format.GML(); }); describe('#readGeometry', function() { @@ -55,6 +56,22 @@ describe('ol.format.GML', function() { expect(coordinate[1]).to.roughlyEqual(2, 1e-9); }); + it('can detect SRS, read and transform a point geometry', function() { + var config = { + featureProjection: 'EPSG:3857' + }; + var text = + '' + + ' 1 2' + + ''; + var g = readGeometry(formatNoSrs, text, config); + expect(g).to.be.an(ol.geom.Point); + var coordinates = g.getCoordinates(); + expect(coordinates.splice(0, 2)).to.eql( + ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857')); + }); + it('can read and write a point geometry in EPSG:4326', function() { var text = '