# 判断是否交叉(booleanCrosses)
> npm install @turf/boolean-crosses
Boolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries.
接收2个要素,判断它们是否有相交点(相交产生的几何图形维度需要小于两个源几何图形的最大维度,并且相交集位于2个源图形的内部)。
注意:经过测试,只有在传入1个面与一条线时结果正确,不可传入点,不可传入2个面要素,2 条线就算相交返回结果可能也是 false,例如:
let result = turf.booleanCrosses( { type: "LineString", coordinates: [ [119.9669122695923, 28.13561248779297], [120.1262140274048, 28.027122497558594], [120.25942325592042, 27.999656677246094], ], }, { type: "LineString", coordinates: [ [120.09737491607667, 28.11913299560547], [120.02459049224855, 28.08068084716797], [119.94905948638917, 28.08617401123047], ], } );
参数
参数 | 类型 | 描述 |
---|---|---|
feature1 | Geometry|Feature | GeoJSON |
feature2 | Geometry|Feature | GeoJSON |
返回
boolean - true/false
示例
var line1 = turf.lineString([
[-2, 2],
[4, 2],
]);
var line2 = turf.lineString([
[1, 1],
[1, 2],
[1, 3],
[1, 4],
]);
var cross = turf.booleanCrosses(line1, line2);
//=true
基础用法
Copy
面与他的边框线
Copy
动态绘制
Copy