Skip to content

Commit

Permalink
Fixing boolean-intersects docs (#2593)
Browse files Browse the repository at this point in the history
* Improve boolean-intersects docs

* Improving boolean-intersects docs

* adding boolean-intersects to documentation.yml

* moved addtomap to end and colored markers

---------

Co-authored-by: James Beard <james@smallsaucepan.com>
  • Loading branch information
izzybps and smallsaucepan authored Jul 25, 2024
1 parent 499c8d5 commit 1f4bef8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
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

0 comments on commit 1f4bef8

Please sign in to comment.