Skip to content

描述 ​

如果第一个几何图形完全在第二个几何图形内部,则 booleanWithin 返回 true。两个几何图形的内部必须相交,且几何图形 a 的内部和边界不得与几何图形 b 的外部相交。

booleanWithin(a, b) 等价于 booleanContains(b, a)

参数 ​

名称类型描述
feature1Geometry | Feature<any>GeoJSON Feature 或 Geometry
feature2Geometry | Feature<any>GeoJSON Feature 或 Geometry

返回值 ​

boolean true/false

示例 ​

javascript
var line = turf.lineString([
  [1, 1],
  [1, 2],
  [1, 3],
  [1, 4],
]);
var point = turf.point([1, 2]);

turf.booleanWithin(point, line);
//=true

安装 ​

javascript
$ npm install @turf/boolean-within

import { booleanWithin } from "@turf/boolean-within";
const result = booleanWithin(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.booleanWithin(...);