Don't return a feature if there are no coordinates

This commit is contained in:
Tom Payne
2014-04-29 15:05:30 +02:00
parent 3742b3c816
commit b64c63ea24
2 changed files with 32 additions and 0 deletions

View File

@@ -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;

View File

@@ -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');