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/polygon-smooth`](polygon-smooth) Clean up a typo (#2293)
- [`@turf/nearest-point-on-line`](nearest-point-on-line) Clean up typescript types (#2296) - [`@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-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) - Remove Bower references (#2146)
- Fix typo in README (#2313) - Fix typo in README (#2313)

View File

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

View File

@ -4,7 +4,7 @@
## booleanIntersects ## 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 ### Parameters
@ -14,11 +14,20 @@ Boolean-intersects returns (TRUE) two geometries intersect.
### Examples ### Examples
```javascript ```javascript
var point = turf.point([2, 2]); var point1 = turf.point([2, 2]);
var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); 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 //=true
//addToMap
var addToMap = [point1, point2, line];
point1.properties['marker-color'] = '#f00'
point2.properties['marker-color'] = '#0f0'
``` ```
Returns **[boolean][3]** true/false Returns **[boolean][3]** true/false

View File

@ -3,18 +3,27 @@ import { booleanDisjoint } from "@turf/boolean-disjoint";
import { flattenEach } from "@turf/meta"; 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 * @name booleanIntersects
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
* @returns {boolean} true/false * @returns {boolean} true/false
* @example * @example
* var point = turf.point([2, 2]); * var point1 = turf.point([2, 2]);
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); * 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 * //=true
*
* //addToMap
* var addToMap = [point1, point2, line];
* point1.properties['marker-color'] = '#f00'
* point2.properties['marker-color'] = '#0f0'
*/ */
function booleanIntersects( function booleanIntersects(
feature1: Feature<any> | Geometry, feature1: Feature<any> | Geometry,