Fixing boolean-intersects docs (#2593)

* 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>
This commit is contained in:
Isaque Borges 2024-07-25 20:02:45 -03:00 committed by GitHub
parent 499c8d5063
commit 1f4bef87a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 9 deletions

View File

@ -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)

View File

@ -139,6 +139,7 @@ toc:
- booleanCrosses
- booleanDisjoint
- booleanEqual
- booleanIntersects
- booleanOverlap
- booleanParallel
- booleanPointInPolygon

View File

@ -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
@ -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

View File

@ -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,