diff --git a/src/ol/render/webgl/linestringreplay/index.js b/src/ol/render/webgl/linestringreplay/index.js index 3e71e3b2ff..911ca33955 100644 --- a/src/ol/render/webgl/linestringreplay/index.js +++ b/src/ol/render/webgl/linestringreplay/index.js @@ -352,10 +352,20 @@ ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiL */ ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function( flatCoordinates, holeFlatCoordinates, stride) { + if (!ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, + flatCoordinates.length, stride)) { + flatCoordinates.push(flatCoordinates[0]); + flatCoordinates.push(flatCoordinates[1]); + } this.drawCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride); if (holeFlatCoordinates.length) { var i, ii; for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) { + if (!ol.geom.flat.topology.lineStringIsClosed(holeFlatCoordinates[i], 0, + holeFlatCoordinates[i].length, stride)) { + holeFlatCoordinates[i].push(holeFlatCoordinates[i][0]); + holeFlatCoordinates[i].push(holeFlatCoordinates[i][1]); + } this.drawCoordinates_(holeFlatCoordinates[i], 0, holeFlatCoordinates[i].length, stride); } diff --git a/test/spec/ol/render/webgl/polygonreplay.test.js b/test/spec/ol/render/webgl/polygonreplay.test.js index e6b4e55064..d67431fc59 100644 --- a/test/spec/ol/render/webgl/polygonreplay.test.js +++ b/test/spec/ol/render/webgl/polygonreplay.test.js @@ -37,25 +37,25 @@ describe('ol.render.webgl.PolygonReplay', function() { [[[1000, 2000], [1200, 2000], [1200, 3000]]] ); replay.drawPolygon(polygon1, null); - expect(replay.vertices).to.have.length(6); + expect(replay.vertices).to.have.length(8); expect(replay.indices).to.have.length(3); expect(replay.vertices).to.eql([ - 1200, 3000, 1200, 2000, 1000, 2000]); + 1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000]); expect(replay.indices).to.eql([2, 0, 1]); var polygon2 = new ol.geom.Polygon( [[[4000, 2000], [4200, 2000], [4200, 3000]]] ); replay.drawPolygon(polygon2, null); - expect(replay.vertices).to.have.length(12); + expect(replay.vertices).to.have.length(16); expect(replay.indices).to.have.length(6); expect(replay.vertices).to.eql([ - 1200, 3000, 1200, 2000, 1000, 2000, - 4200, 3000, 4200, 2000, 4000, 2000 + 1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000, + 4000, 2000, 4200, 3000, 4200, 2000, 4000, 2000 ]); - expect(replay.indices).to.eql([2, 0, 1, 5, 3, 4]); + expect(replay.indices).to.eql([2, 0, 1, 6, 4, 5]); }); }); @@ -70,14 +70,14 @@ describe('ol.render.webgl.PolygonReplay', function() { [[[4000, 2000], [4200, 2000], [4200, 3000]]] ]); replay.drawMultiPolygon(multiPolygon, null); - expect(replay.vertices).to.have.length(12); + expect(replay.vertices).to.have.length(16); expect(replay.indices).to.have.length(6); expect(replay.vertices).to.eql([ - 1200, 3000, 1200, 2000, 1000, 2000, - 4200, 3000, 4200, 2000, 4000, 2000 + 1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000, + 4000, 2000, 4200, 3000, 4200, 2000, 4000, 2000 ]); - expect(replay.indices).to.eql([2, 0, 1, 5, 3, 4]); + expect(replay.indices).to.eql([2, 0, 1, 6, 4, 5]); }); });