diff --git a/src/ol/format/igcformat.js b/src/ol/format/igcformat.js index 8be575dd04..f73902a934 100644 --- a/src/ol/format/igcformat.js +++ b/src/ol/format/igcformat.js @@ -156,6 +156,9 @@ ol.format.IGC.prototype.readFeatureFromText = function(text) { } } } + if (flatCoordinates.length === 0) { + return null; + } var lineString = new ol.geom.LineString(null); var layout = altitudeMode == ol.format.IGCZ.NONE ? ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM; diff --git a/test/spec/ol/format/igcformattest.js b/test/spec/ol/format/igcformattest.js new file mode 100644 index 0000000000..d77e1fc08e --- /dev/null +++ b/test/spec/ol/format/igcformattest.js @@ -0,0 +1,29 @@ +goog.provide('ol.test.format.IGC'); + + +describe('ol.format.IGC', function() { + + var format; + beforeEach(function() { + format = new ol.format.IGC(); + }); + + describe('#readFeature', function() { + + it('does not read invalid features', function() { + expect(format.readFeature('invalid')).to.be(null); + }); + + }); + + describe('#readFeatures', function() { + + it('does not read invalid features', function() { + expect(format.readFeatures('invalid')).to.be.empty(); + }); + + }); + +}); + +goog.require('ol.format.IGC');