From 2e18f077c80245d14ab4826c2b282906d0f775ae Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Tue, 23 Sep 2014 15:35:12 +0200 Subject: [PATCH] Correctly parse GML coordinates with capital E in scientific notation --- src/ol/format/gmlformat.js | 2 +- test/spec/ol/format/gmlformat.test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ol/format/gmlformat.js b/src/ol/format/gmlformat.js index 8df6e5f05a..9f7e2dc6d9 100644 --- a/src/ol/format/gmlformat.js +++ b/src/ol/format/gmlformat.js @@ -699,7 +699,7 @@ ol.format.GML.readFlatCoordinatesFromNode_ = function(node, objectStack) { */ ol.format.GML.readFlatPos_ = function(node, objectStack) { var s = ol.xml.getAllTextContent(node, false); - var re = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*/; + var re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/; /** @type {Array.} */ var flatCoordinates = []; var m; diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js index 143e846ade..05fcd09388 100644 --- a/test/spec/ol/format/gmlformat.test.js +++ b/test/spec/ol/format/gmlformat.test.js @@ -34,6 +34,25 @@ describe('ol.format.GML', function() { expect(serialized.firstElementChild).to.xmleql(ol.xml.load(text)); }); + it('can read a point geometry with scientific notation', function() { + var text = + '' + + ' 1E7 2' + + ''; + var g = readGeometry(format, text); + expect(g).to.be.an(ol.geom.Point); + expect(g.getCoordinates()).to.eql([10000000, 2, 0]); + text = + '' + + ' 1e7 2' + + ''; + g = readGeometry(format, text); + expect(g).to.be.an(ol.geom.Point); + expect(g.getCoordinates()).to.eql([10000000, 2, 0]); + }); + it('can read, transform and write a point geometry', function() { var config = { featureProjection: 'EPSG:3857'