booleanOverlap
描述
¥Description
比较两个相同维度的几何图形,如果它们的交集结果与两者不同但维度相同,则返回 true。它适用于多边形/多边形、线串/线串、多点/多点、多线串/多线串和多多边形/多多边形。
¥Compares two geometries of the same dimension and returns true if their intersection set results in a geometry different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString, Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.
换句话说,如果两个几何体重叠,且彼此不完全包含,则返回 true。
¥In other words, it returns true if the two geometries overlap, provided that neither completely contains the other.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
feature1 | 几何图形 | 特性<LineString | MultiLineString | 多边形 | MultiPolygon> | input |
feature2 | 几何图形 | 特性<LineString | MultiLineString | 多边形 | MultiPolygon> | input |
返回
¥Returns
boolean 真/假
¥boolean true/false
示例
¥Examples
var poly1 = turf.polygon([
[
[0, 0],
[0, 5],
[5, 5],
[5, 0],
[0, 0],
],
]);
var poly2 = turf.polygon([
[
[1, 1],
[1, 6],
[6, 6],
[6, 1],
[1, 1],
],
]);
var poly3 = turf.polygon([
[
[10, 10],
[10, 15],
[15, 15],
[15, 10],
[10, 10],
],
]);
turf.booleanOverlap(poly1, poly2);
//=true
turf.booleanOverlap(poly2, poly3);
//=false
安装
¥Installation
$ npm install @turf/boolean-overlap
import { booleanOverlap } from "@turf/boolean-overlap";
const result = booleanOverlap(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.booleanOverlap(...);