From 129757578d41549b6c8b649c2199dfb6e5cf75d1 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 12 Sep 2016 23:42:54 +0200 Subject: [PATCH 1/4] Do not repeat first vertex when closed is true --- src/ol/render/canvas/replay.js | 9 +--- test/spec/ol/renderer/canvas/replay.test.js | 46 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/ol/render/canvas/replay.js b/src/ol/render/canvas/replay.js index 8302579e8c..c092ebe04e 100644 --- a/src/ol/render/canvas/replay.js +++ b/src/ol/render/canvas/replay.js @@ -157,16 +157,11 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat lastRel = nextRel; } - // handle case where there is only one point to append - if (i === offset + stride) { + // When we want to close or there is only one point to append: + if ((close && skipped) || i === offset + stride) { this.coordinates[myEnd++] = lastCoord[0]; this.coordinates[myEnd++] = lastCoord[1]; } - - if (close) { - this.coordinates[myEnd++] = flatCoordinates[offset]; - this.coordinates[myEnd++] = flatCoordinates[offset + 1]; - } return myEnd; }; diff --git a/test/spec/ol/renderer/canvas/replay.test.js b/test/spec/ol/renderer/canvas/replay.test.js index 6c867d076f..493d538dea 100644 --- a/test/spec/ol/renderer/canvas/replay.test.js +++ b/test/spec/ol/renderer/canvas/replay.test.js @@ -169,6 +169,12 @@ describe('ol.render.canvas.Replay', function() { expect(replay.coordinates).to.eql(flat); }); + it('appends polygon coordinates that are within the max extent', function() { + var flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql(flat); + }); + it('works with a single coordinate (inside)', function() { var flat = [-110, 45]; replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); @@ -183,6 +189,14 @@ describe('ol.render.canvas.Replay', function() { expect(replay.coordinates).to.eql(flat); }); + it('always appends first polygon vertex (even if outside)', function() { + // this could be changed, but to make the code simpler for properly + // closing rings, we always add the first point + var flat = [-110, 145, -110, 145]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql(flat); + }); + it('appends points when segments cross (top to bottom)', function() { // this means we get a few extra points when coordinates are not // part of a linestring or ring, but only a few extra @@ -205,18 +219,50 @@ describe('ol.render.canvas.Replay', function() { expect(replay.coordinates).to.eql(flat); }); + it('always appends the first polygon segment (even when outside)', function() { + // this could be changed, but to make the code simpler for properly + // closing rings, we always add the first segment + var flat = [-10, 200, 10, 200, -10, 200]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql(flat); + }); + + it('eliminates segments outside (and not changing rel)', function() { + var flat = [0, 0, 0, 200, 5, 200, 10, 200]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + expect(replay.coordinates).to.eql([0, 0, 0, 200]); + }); + + it('eliminates polygon segments outside (and not changing rel)', function() { + var flat = [0, 0, 0, 200, 5, 200, 10, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql([0, 0, 0, 200, 10, 200, 0, 0]); + }); + it('eliminates segments outside (and not changing rel)', function() { var flat = [0, 0, 0, 200, 10, 200]; replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); expect(replay.coordinates).to.eql([0, 0, 0, 200]); }); + it('includes polygon segments outside (and not changing rel) when on last segment', function() { + var flat = [0, 0, 0, 200, 10, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql(flat); + }); + it('includes outside segments that change relationship', function() { var flat = [0, 0, 0, 200, 200, 200, 250, 200]; replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); expect(replay.coordinates).to.eql([0, 0, 0, 200, 200, 200]); }); + it('includes outside polygon segments that change relationship when on last segment', function() { + var flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + expect(replay.coordinates).to.eql(flat); + }); + }); }); From 430aee95fd32d1fe8ec0fbfa28451394c3533806 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 12 Sep 2016 23:43:32 +0200 Subject: [PATCH 2/4] Only check for fill and stroke once --- src/ol/render/canvas/polygonreplay.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/ol/render/canvas/polygonreplay.js b/src/ol/render/canvas/polygonreplay.js index d60ea7938c..d5f5c76ce2 100644 --- a/src/ol/render/canvas/polygonreplay.js +++ b/src/ol/render/canvas/polygonreplay.js @@ -80,9 +80,6 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo var fill = state.fillStyle !== undefined; var stroke = state.strokeStyle != undefined; var numEnds = ends.length; - if (!fill && !stroke) { - return ends[numEnds - 1]; - } var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH]; this.instructions.push(beginPathInstruction); this.hitDetectionInstructions.push(beginPathInstruction); @@ -178,11 +175,9 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) { var state = this.state_; ol.DEBUG && console.assert(state, 'state should not be null'); - var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; - if (fillStyle === undefined && strokeStyle === undefined) { - return; - } + ol.DEBUG && console.assert(state.fillStyle === undefined && strokeStyle === undefined, + 'fillStyle or strokeStyle should be defined'); if (strokeStyle !== undefined) { ol.DEBUG && console.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); From e7bc7121d61d795457cd9d15165c40b2ad8f0cc6 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 13 Sep 2016 01:54:53 +0200 Subject: [PATCH 3/4] Add option to skip first coordinate for use with closePath() --- src/ol/render/canvas/imagereplay.js | 2 +- src/ol/render/canvas/linestringreplay.js | 2 +- src/ol/render/canvas/polygonreplay.js | 4 +- src/ol/render/canvas/replay.js | 12 ++-- src/ol/render/canvas/textreplay.js | 2 +- test/spec/ol/renderer/canvas/replay.test.js | 66 ++++++++++++++++----- 6 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/ol/render/canvas/imagereplay.js b/src/ol/render/canvas/imagereplay.js index 86ef562ce2..3d14617a3a 100644 --- a/src/ol/render/canvas/imagereplay.js +++ b/src/ol/render/canvas/imagereplay.js @@ -109,7 +109,7 @@ ol.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay); */ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { return this.appendFlatCoordinates( - flatCoordinates, offset, end, stride, false); + flatCoordinates, offset, end, stride, false, false); }; diff --git a/src/ol/render/canvas/linestringreplay.js b/src/ol/render/canvas/linestringreplay.js index b0aa86c0fa..83ccbc483b 100644 --- a/src/ol/render/canvas/linestringreplay.js +++ b/src/ol/render/canvas/linestringreplay.js @@ -75,7 +75,7 @@ ol.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay); ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) { var myBegin = this.coordinates.length; var myEnd = this.appendFlatCoordinates( - flatCoordinates, offset, end, stride, false); + flatCoordinates, offset, end, stride, false, false); var moveToLineToInstruction = [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd]; this.instructions.push(moveToLineToInstruction); diff --git a/src/ol/render/canvas/polygonreplay.js b/src/ol/render/canvas/polygonreplay.js index d5f5c76ce2..5d93591df8 100644 --- a/src/ol/render/canvas/polygonreplay.js +++ b/src/ol/render/canvas/polygonreplay.js @@ -87,7 +87,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo var end = ends[i]; var myBegin = this.coordinates.length; var myEnd = this.appendFlatCoordinates( - flatCoordinates, offset, end, stride, true); + flatCoordinates, offset, end, stride, true, !stroke); var moveToLineToInstruction = [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd]; this.instructions.push(moveToLineToInstruction); @@ -148,7 +148,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f var stride = circleGeometry.getStride(); var myBegin = this.coordinates.length; this.appendFlatCoordinates( - flatCoordinates, 0, flatCoordinates.length, stride, false); + flatCoordinates, 0, flatCoordinates.length, stride, false, false); var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH]; var circleInstruction = [ol.render.canvas.Instruction.CIRCLE, myBegin]; this.instructions.push(beginPathInstruction, circleInstruction); diff --git a/src/ol/render/canvas/replay.js b/src/ol/render/canvas/replay.js index c092ebe04e..2136448a2b 100644 --- a/src/ol/render/canvas/replay.js +++ b/src/ol/render/canvas/replay.js @@ -120,14 +120,18 @@ ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext); * @param {number} offset Offset. * @param {number} end End. * @param {number} stride Stride. - * @param {boolean} close Close. + * @param {boolean} closed Last input coordinate equals first. + * @param {boolean} skipFirst Skip first coordinate. * @protected * @return {number} My end. */ -ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, close) { +ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) { var myEnd = this.coordinates.length; var extent = this.getBufferedMaxExtent(); + if (skipFirst) { + offset += stride; + } var lastCoord = [flatCoordinates[offset], flatCoordinates[offset + 1]]; var nextCoord = [NaN, NaN]; var skipped = true; @@ -157,8 +161,8 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat lastRel = nextRel; } - // When we want to close or there is only one point to append: - if ((close && skipped) || i === offset + stride) { + // Last coordinate equals first or only one point to append: + if ((closed && skipped) || i === offset + stride) { this.coordinates[myEnd++] = lastCoord[0]; this.coordinates[myEnd++] = lastCoord[1]; } diff --git a/src/ol/render/canvas/textreplay.js b/src/ol/render/canvas/textreplay.js index 7453382063..ba2794f6b4 100644 --- a/src/ol/render/canvas/textreplay.js +++ b/src/ol/render/canvas/textreplay.js @@ -115,7 +115,7 @@ ol.render.canvas.TextReplay.prototype.drawText = function(flatCoordinates, offse this.beginGeometry(geometry, feature); var myBegin = this.coordinates.length; var myEnd = - this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false); + this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false); var fill = !!this.textFillState_; var stroke = !!this.textStrokeState_; var drawTextInstruction = [ diff --git a/test/spec/ol/renderer/canvas/replay.test.js b/test/spec/ol/renderer/canvas/replay.test.js index 493d538dea..68ee494d1c 100644 --- a/test/spec/ol/renderer/canvas/replay.test.js +++ b/test/spec/ol/renderer/canvas/replay.test.js @@ -165,19 +165,25 @@ describe('ol.render.canvas.Replay', function() { it('appends coordinates that are within the max extent', function() { var flat = [-110, 45, 110, 45, 110, -45, -110, -45]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); it('appends polygon coordinates that are within the max extent', function() { var flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql(flat); }); + it('appends polygon coordinates that are within the max extent (skipping first)', function() { + var flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([110, 45, 110, -45, -110, -45, -110, 45]); + }); + it('works with a single coordinate (inside)', function() { var flat = [-110, 45]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); @@ -185,7 +191,7 @@ describe('ol.render.canvas.Replay', function() { // this could be changed, but to make the code simpler for properly // closing rings, we always add the first point var flat = [-110, 145]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); @@ -193,21 +199,27 @@ describe('ol.render.canvas.Replay', function() { // this could be changed, but to make the code simpler for properly // closing rings, we always add the first point var flat = [-110, 145, -110, 145]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql(flat); }); + it('skips first polygon vertex upon request (also when outside)', function() { + var flat = [-110, 145, -110, 145]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([-110, 145]); + }); + it('appends points when segments cross (top to bottom)', function() { // this means we get a few extra points when coordinates are not // part of a linestring or ring, but only a few extra var flat = [0, 200, 0, -200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); it('appends points when segments cross (top to inside)', function() { var flat = [0, 200, 0, 0]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); @@ -215,7 +227,7 @@ describe('ol.render.canvas.Replay', function() { // this could be changed, but to make the code simpler for properly // closing rings, we always add the first segment var flat = [-10, 200, 10, 200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql(flat); }); @@ -223,46 +235,70 @@ describe('ol.render.canvas.Replay', function() { // this could be changed, but to make the code simpler for properly // closing rings, we always add the first segment var flat = [-10, 200, 10, 200, -10, 200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql(flat); }); + it('skips first polygon segment upon request (also when outside)', function() { + var flat = [-10, 200, 10, 200, -10, 200]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([10, 200, -10, 200]); + }); + it('eliminates segments outside (and not changing rel)', function() { var flat = [0, 0, 0, 200, 5, 200, 10, 200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql([0, 0, 0, 200]); }); it('eliminates polygon segments outside (and not changing rel)', function() { var flat = [0, 0, 0, 200, 5, 200, 10, 200, 0, 0]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql([0, 0, 0, 200, 10, 200, 0, 0]); }); + it('eliminates polygon segments outside (skipping first and not changing rel)', function() { + var flat = [0, 0, 0, 10, 0, 200, 5, 200, 10, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([0, 10, 0, 200, 10, 200, 0, 0]); + }); + it('eliminates segments outside (and not changing rel)', function() { var flat = [0, 0, 0, 200, 10, 200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql([0, 0, 0, 200]); }); it('includes polygon segments outside (and not changing rel) when on last segment', function() { var flat = [0, 0, 0, 200, 10, 200, 0, 0]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql(flat); }); + it('includes polygon segments outside (skipping first and not changing rel) when on last segment', function() { + var flat = [0, 0, 0, 200, 10, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([0, 200, 10, 200, 0, 0]); + }); + it('includes outside segments that change relationship', function() { var flat = [0, 0, 0, 200, 200, 200, 250, 200]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, false); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false); expect(replay.coordinates).to.eql([0, 0, 0, 200, 200, 200]); }); it('includes outside polygon segments that change relationship when on last segment', function() { var flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0]; - replay.appendFlatCoordinates(flat, 0, flat.length, 2, true); + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false); expect(replay.coordinates).to.eql(flat); }); + it('includes outside polygon segments that change relationship when on last segment (when skipping first)', function() { + var flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0]; + replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true); + expect(replay.coordinates).to.eql([0, 200, 200, 200, 250, 200, 0, 0]); + }); + }); }); From c8c1578928e8b87e6e4cdc28a00ba8cb8b8b536e Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 13 Sep 2016 16:32:55 +0200 Subject: [PATCH 4/4] Add rendering tests for simplified polygons --- .../vector-canvas-simplified-fill.png | Bin 0 -> 254 bytes .../vector-canvas-simplified-stroke.png | Bin 0 -> 392 bytes .../expected/vector-canvas-simplified.png | Bin 0 -> 341 bytes test_rendering/spec/ol/layer/vector.test.js | 87 ++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 test_rendering/spec/ol/layer/expected/vector-canvas-simplified-fill.png create mode 100644 test_rendering/spec/ol/layer/expected/vector-canvas-simplified-stroke.png create mode 100644 test_rendering/spec/ol/layer/expected/vector-canvas-simplified.png diff --git a/test_rendering/spec/ol/layer/expected/vector-canvas-simplified-fill.png b/test_rendering/spec/ol/layer/expected/vector-canvas-simplified-fill.png new file mode 100644 index 0000000000000000000000000000000000000000..47956d701140e5ce3166398ee5877cf7bd1a5f02 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^DImBDjPD$Z{2MWYKKmQ1TFT5pe8MXyOQ>l9Hc}6PN>+CU1I{xONiA NiJq>0F6*2UngC)cOmP4J literal 0 HcmV?d00001 diff --git a/test_rendering/spec/ol/layer/expected/vector-canvas-simplified-stroke.png b/test_rendering/spec/ol/layer/expected/vector-canvas-simplified-stroke.png new file mode 100644 index 0000000000000000000000000000000000000000..035e1537d27546e8a37f2b5b145c80e5202b30e8 GIT binary patch literal 392 zcmeAS@N?(olHy`uVBq!ia0vp^DIm0 zX830q9-EfLetD8?M5}7YM4u=A52OWz@7F!}X1Ipc{9gO-vq0@=;6UoGSu+oxyLXl^ z@5j$|+v^G*m8IQFdv^Hu*S+V@+})NR_r6ZDdgjdKbN5_-y6iGvp5^}MPnSIgiOW1W z-_FGUx%BemdihVjZ|Ac_x=#>HF=xr-VI68%Pw9ku?(3@x8GRp;LE+=+>gTe~DWM4f DKFx1N literal 0 HcmV?d00001 diff --git a/test_rendering/spec/ol/layer/expected/vector-canvas-simplified.png b/test_rendering/spec/ol/layer/expected/vector-canvas-simplified.png new file mode 100644 index 0000000000000000000000000000000000000000..26c028bcda55b21b45432783f4f761c4cab21e56 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^DImqTkl zPK9S}c}LFNSbByp?dmUIHWuMhCe0@@6+hpu;|1zN1OJx)&h6h=&6V?`ivN1uhx|P` z)wj!bDZfPOR_~X3j&UD;JiDT>|;p)78&qol`;+02K3qYybcN literal 0 HcmV?d00001 diff --git a/test_rendering/spec/ol/layer/vector.test.js b/test_rendering/spec/ol/layer/vector.test.js index 0ab45d9762..563d231fb4 100644 --- a/test_rendering/spec/ol/layer/vector.test.js +++ b/test_rendering/spec/ol/layer/vector.test.js @@ -271,4 +271,91 @@ describe('ol.rendering.layer.Vector', function() { }); }); + describe('Polygon simplification', function() { + + var layer, map; + + beforeEach(function() { + var src = new ol.source.Vector({ + features: [ + new ol.Feature(new ol.geom.Polygon([[ + [-22, 58], + [-22, 78], + [-9, 78], + [-9, 58], + [-22, 58] + ]])), + new ol.Feature(new ol.geom.Polygon([[ + [-9, 58], + [-9, 78], + [4, 78], + [4, 58], + [-9, 58] + ]])) + ] + }); + layer = new ol.layer.Vector({ + renderBuffer: 0, + source: src + }); + var view = new ol.View({ + center: [-9.5, 78], + zoom: 2, + projection: 'EPSG:4326' + }); + + map = new ol.Map({ + layers: [layer], + target: createMapDiv(100, 100), + view: view + }); + }); + + afterEach(function() { + disposeMap(map); + }); + + it('renders partially out-of-view polygons with a fill and stroke', function(done) { + layer.setStyle(new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: [0, 0, 0, 1], + width: 2 + }), + fill: new ol.style.Fill({ + color: [255, 0, 0, 1] + }) + })); + map.once('postrender', function() { + expectResemble(map, 'spec/ol/layer/expected/vector-canvas-simplified.png', + IMAGE_TOLERANCE, done); + }); + }); + + it('renders partially out-of-view polygons with a fill', function(done) { + layer.setStyle(new ol.style.Style({ + fill: new ol.style.Fill({ + color: [0, 0, 0, 1] + }) + })); + map.once('postrender', function() { + expectResemble(map, 'spec/ol/layer/expected/vector-canvas-simplified-fill.png', + IMAGE_TOLERANCE, done); + }); + }); + + it('renders partially out-of-view polygons with a stroke', function(done) { + layer.setStyle(new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: [0, 0, 0, 1], + width: 2 + }) + })); + map.once('postrender', function() { + expectResemble(map, 'spec/ol/layer/expected/vector-canvas-simplified-stroke.png', + IMAGE_TOLERANCE, done); + }); + }); + + }); + });