diff --git a/src/connect_edges.js b/src/connect_edges.js index 0ce5c43..48daeb9 100644 --- a/src/connect_edges.js +++ b/src/connect_edges.js @@ -96,7 +96,13 @@ function initializeContourFromContext(event, contours, contourId) { // in an earlier iteration, otherwise it wouldn't be possible that it is "previous in // result". const lowerContourId = prevInResult.outputContourId; - const lowerResultTransition = prevInResult.resultTransition; + let lowerResultTransition = prevInResult.resultTransition; + if (!event.isExteriorRing && !event.isSubject) { + contour.cull = true; + } else if (!event.isExteriorRing && prevInResult.isExteriorRing) { + lowerResultTransition = 1; + } + if (lowerResultTransition > 0) { // We are inside. Now we have to check if the thing below us is another hole or // an exterior contour. diff --git a/src/index.js b/src/index.js index b3a3f69..c92e5b1 100644 --- a/src/index.js +++ b/src/index.js @@ -80,7 +80,7 @@ export default function boolean(subject, clipping, operation) { const polygons = []; for (let i = 0; i < contours.length; i++) { let contour = contours[i]; - if (contour.isExterior()) { + if (contour.isExterior() && contour.cull !== true) { // The exterior ring goes first let rings = [contour.points]; // Followed by holes if any diff --git a/test/fixtures/issue69.geojson b/test/fixtures/issue69.geojson new file mode 100644 index 0000000..98db265 --- /dev/null +++ b/test/fixtures/issue69.geojson @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [[[2, 0],[10, 10],[10, 0],[2, 0]]] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [[[5, 1],[12, 1],[12, 9],[5, 9],[5, 1]],[[6, 2],[11, 8],[6, 8],[6, 2]]] + } + } + ] +} \ No newline at end of file