Skip to content

Commit

Permalink
Merge pull request openlayers#2024 from twpayne/igc-invalid
Browse files Browse the repository at this point in the history
Fix IGC handling of invalid IGC files
  • Loading branch information
twpayne committed Apr 29, 2014
2 parents 3742b3c + b64c63e commit debbd83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ol/format/igcformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions test/spec/ol/format/igcformattest.js
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit debbd83

Please sign in to comment.