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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Changelog is no longer maintained. See Turf Github [releases](https://github.com
- [`@turf/polygon-smooth`](polygon-smooth) Clean up a typo (#2293)
- [`@turf/nearest-point-on-line`](nearest-point-on-line) Clean up typescript types (#2296)
- [`@turf/boolean-touches`](boolean-touches) Add boolean-touches to docs (#2431)
- [`@turf/boolean-equals`](boolean-equals) Improve docs (#2412)
- [`@turf/boolean-equal`](boolean-equal) Improve docs (#2412)

- Remove Bower references (#2146)
- Fix typo in README (#2313)
Expand Down
1 change: 1 addition & 0 deletions documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ toc:
- booleanCrosses
- booleanDisjoint
- booleanEqual
- booleanIntersects
- booleanOverlap
- booleanParallel
- booleanPointInPolygon
Expand Down
17 changes: 13 additions & 4 deletions packages/turf-boolean-intersects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## booleanIntersects

Boolean-intersects returns (TRUE) two geometries intersect.
Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.

### Parameters

Expand All @@ -14,11 +14,20 @@ Boolean-intersects returns (TRUE) two geometries intersect.
### Examples

```javascript
var point = turf.point([2, 2]);
var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
var point1 = turf.point([2, 2]);
var point2 = turf.point([1, 2]);
var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);

turf.booleanIntersects(line, point);
turf.booleanIntersects(line, point1);
//=false

turf.booleanIntersects(line, point2);
//=true

//addToMap
var addToMap = [point1, point2, line];
point1.properties['marker-color'] = '#f00'
point2.properties['marker-color'] = '#0f0'
```

Returns **[boolean][3]** true/false
Expand Down
17 changes: 13 additions & 4 deletions packages/turf-boolean-intersects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import { booleanDisjoint } from "@turf/boolean-disjoint";
import { flattenEach } from "@turf/meta";

/**
* Boolean-intersects returns (TRUE) two geometries intersect.
* Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.
*
* @name booleanIntersects
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
* @returns {boolean} true/false
* @example
* var point = turf.point([2, 2]);
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
* var point1 = turf.point([2, 2]);
* var point2 = turf.point([1, 2]);
* var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);
*
* turf.booleanIntersects(line, point);
* turf.booleanIntersects(line, point1);
* //=false
*
* turf.booleanIntersects(line, point2);
* //=true
*
* //addToMap
* var addToMap = [point1, point2, line];
* point1.properties['marker-color'] = '#f00'
* point2.properties['marker-color'] = '#0f0'
*/
function booleanIntersects(
feature1: Feature<any> | Geometry,
Expand Down