Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/turf-boolean-intersects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { flattenEach } from "@turf/meta";
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
* @param {boolean} [options.ignoreSelfIntersections=true] ignore self-intersections on input features
* @returns {boolean} true if geometries intersect, false otherwise
* @example
* var point1 = turf.point([2, 2]);
Expand All @@ -30,13 +30,12 @@ import { flattenEach } from "@turf/meta";
function booleanIntersects(
feature1: Feature<any> | Geometry,
feature2: Feature<any> | Geometry,
options: {
{
ignoreSelfIntersections = true,
}: {
ignoreSelfIntersections?: boolean;
} = {}
) {
const ignoreSelfIntersections: boolean =
options.ignoreSelfIntersections ?? false;

let bool = false;
flattenEach(feature1, (flatten1) => {
flattenEach(feature2, (flatten2) => {
Expand Down
40 changes: 20 additions & 20 deletions packages/turf-boolean-intersects/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,62 +122,62 @@ test("turf-boolean-intersects with ignoreSelfIntersections option", (t) => {
selfIntersectingLineString,
nonIntersectingLineString
);
t.true(
t.false(
result,
"[true] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
"[false] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
);
result = intersects(selfIntersectingLineString, intersectingLineString);
t.true(
result,
"[true] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
);
result = intersects(selfIntersectingLineString, intersectingPolygon);
t.true(
result,
"[true] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
);
result = intersects(selfIntersectingLineString, nonIntersectingPolygon);
t.true(
t.false(
result,
"[true] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
"[false] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
);

// Test with ignoringSelfIntersections option
result = intersects(selfIntersectingLineString, nonIntersectingLineString, {
ignoreSelfIntersections: true,
ignoreSelfIntersections: false,
});
t.false(
t.true(
result,
"[false] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
"[true] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
);
result = intersects(selfIntersectingLineString, intersectingLineString, {
ignoreSelfIntersections: true,
ignoreSelfIntersections: false,
});
t.true(
result,
"[true] " +
"selfIntersectingLineString-LineString (ignoreSelfIntersections=true)"
"selfIntersectingLineString-LineString (ignoreSelfIntersections=false)"
);
result = intersects(selfIntersectingLineString, intersectingPolygon, {
ignoreSelfIntersections: true,
ignoreSelfIntersections: false,
});
t.true(
result,
"[true] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
);
result = intersects(selfIntersectingLineString, nonIntersectingPolygon, {
ignoreSelfIntersections: true,
ignoreSelfIntersections: false,
});
t.false(
t.true(
result,
"[false] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
"[true] " +
"selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
);

t.end();
Expand Down
Loading