Skip to content

Commit d1a2c58

Browse files
pm0usmallsaucepan
andauthored
Reverted self intersection behavior of boolean-intersect. update tests (#2773)
Co-authored-by: James Beard <[email protected]>
1 parent 5a9d40d commit d1a2c58

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

packages/turf-boolean-intersects/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { flattenEach } from "@turf/meta";
99
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
1010
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
1111
* @param {Object} [options={}] Optional parameters
12-
* @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
12+
* @param {boolean} [options.ignoreSelfIntersections=true] ignore self-intersections on input features
1313
* @returns {boolean} true if geometries intersect, false otherwise
1414
* @example
1515
* var point1 = turf.point([2, 2]);
@@ -30,13 +30,12 @@ import { flattenEach } from "@turf/meta";
3030
function booleanIntersects(
3131
feature1: Feature<any> | Geometry,
3232
feature2: Feature<any> | Geometry,
33-
options: {
33+
{
34+
ignoreSelfIntersections = true,
35+
}: {
3436
ignoreSelfIntersections?: boolean;
3537
} = {}
3638
) {
37-
const ignoreSelfIntersections: boolean =
38-
options.ignoreSelfIntersections ?? false;
39-
4039
let bool = false;
4140
flattenEach(feature1, (flatten1) => {
4241
flattenEach(feature2, (flatten2) => {

packages/turf-boolean-intersects/test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,62 +122,62 @@ test("turf-boolean-intersects with ignoreSelfIntersections option", (t) => {
122122
selfIntersectingLineString,
123123
nonIntersectingLineString
124124
);
125-
t.true(
125+
t.false(
126126
result,
127-
"[true] " +
128-
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
127+
"[false] " +
128+
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
129129
);
130130
result = intersects(selfIntersectingLineString, intersectingLineString);
131131
t.true(
132132
result,
133133
"[true] " +
134-
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
134+
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
135135
);
136136
result = intersects(selfIntersectingLineString, intersectingPolygon);
137137
t.true(
138138
result,
139139
"[true] " +
140-
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
140+
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
141141
);
142142
result = intersects(selfIntersectingLineString, nonIntersectingPolygon);
143-
t.true(
143+
t.false(
144144
result,
145-
"[true] " +
146-
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
145+
"[false] " +
146+
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
147147
);
148148

149149
// Test with ignoringSelfIntersections option
150150
result = intersects(selfIntersectingLineString, nonIntersectingLineString, {
151-
ignoreSelfIntersections: true,
151+
ignoreSelfIntersections: false,
152152
});
153-
t.false(
153+
t.true(
154154
result,
155-
"[false] " +
156-
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
155+
"[true] " +
156+
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
157157
);
158158
result = intersects(selfIntersectingLineString, intersectingLineString, {
159-
ignoreSelfIntersections: true,
159+
ignoreSelfIntersections: false,
160160
});
161161
t.true(
162162
result,
163163
"[true] " +
164-
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
164+
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
165165
);
166166
result = intersects(selfIntersectingLineString, intersectingPolygon, {
167-
ignoreSelfIntersections: true,
167+
ignoreSelfIntersections: false,
168168
});
169169
t.true(
170170
result,
171171
"[true] " +
172-
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
172+
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
173173
);
174174
result = intersects(selfIntersectingLineString, nonIntersectingPolygon, {
175-
ignoreSelfIntersections: true,
175+
ignoreSelfIntersections: false,
176176
});
177-
t.false(
177+
t.true(
178178
result,
179-
"[false] " +
180-
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
179+
"[true] " +
180+
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
181181
);
182182

183183
t.end();

0 commit comments

Comments
 (0)