Ignore extra dimensions and pad with NaN for missing dimensions

This commit is contained in:
Tim Schaub
2013-08-18 09:57:26 -04:00
parent 9b90129b24
commit 0f9e269057
5 changed files with 22 additions and 29 deletions
+19
View File
@@ -40,6 +40,25 @@ describe('ol.geom.SharedVertices', function() {
expect(vertices.coordinates).to.eql([1, 2, 3, 4, 5, 6]);
});
it('ignores extra dimensions', function() {
var vertices = new ol.geom.SharedVertices({dimension: 2});
expect(vertices.coordinates.length).to.be(0);
vertices.add([[1, 2], [3, 4, 5], [6, 7]]);
expect(vertices.coordinates).to.eql([1, 2, 3, 4, 6, 7]);
vertices.add([[8, 9, 10]]);
expect(vertices.coordinates).to.eql([1, 2, 3, 4, 6, 7, 8, 9]);
});
it('pads with NaN when dimension not provided', function() {
var vertices = new ol.geom.SharedVertices({dimension: 3});
expect(vertices.coordinates.length).to.be(0);
vertices.add([[1, 2], [3, 4, 5], [6, 7]]);
expect(vertices.coordinates).to.eql([1, 2, NaN, 3, 4, 5, 6, 7, NaN]);
});
it('returns an identifier for coordinate access', function() {
var vertices = new ol.geom.SharedVertices();
var id = vertices.add([[1, 2], [3, 4]]);