Skip to content

Commit d5bbc2a

Browse files
committed
Fix Polygon clipping issue.
The missing endpoint was causing issues with the algorithm.
1 parent 37f64b7 commit d5bbc2a

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

d3.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5515,7 +5515,7 @@
55155515
polygonStart: function() {
55165516
clip.point = pointPolygon;
55175517
clip.lineStart = linePolygon;
5518-
clip.lineEnd = d3_noop;
5518+
clip.lineEnd = lineEndPolygon;
55195519
},
55205520
polygonEnd: function() {
55215521
clip.point = point;
@@ -5554,6 +5554,9 @@
55545554
function linePolygon() {
55555555
polygon.push(ring = []);
55565556
}
5557+
function lineEndPolygon() {
5558+
ring.push(ring[0]);
5559+
}
55575560
};
55585561
}
55595562
function d3_geo_clipPolygon(polygon, clipRing, interpolate, listener) {
@@ -5574,7 +5577,7 @@
55745577
if (clean & 1) {
55755578
segment = ringSegments[0];
55765579
visibleArea += d3_geo_clipAreaRing(segment, d3_geo_clipRotation);
5577-
var n = segment.length, i = -1, point;
5580+
var n = segment.length - 1, i = -1, point;
55785581
listener.lineStart();
55795582
while (++i < n) listener.point((point = segment[i])[0], point[1]);
55805583
listener.lineEnd();

0 commit comments

Comments
 (0)