booleanPointInPolygon
描述
¥Description
获取 点 和 多边形 或 MultiPolygon 点,并确定点是否位于多边形内。多边形可以是凸的,也可以是凹的。该函数会考虑空洞。
¥Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
point | 坐标系 | 输入点 |
polygon | 特性<多边形 | MultiPolygon> | 输入多边形或多多边形 |
options? | 对象 | 可选参数(默认 {}) |
options.ignoreBoundary? | boolean | 如果在确定点是否位于多边形内部时应忽略多边形边界,则为 True,否则为 false。(默认 false) |
返回
¥Returns
如果点位于多边形内,则为 boolean true
;如果点不在多边形内,则使用 false
¥boolean true
if the Point is inside the Polygon; false
if the Point is not inside the Polygon
示例
¥Examples
var pt = turf.point([-77, 44]);
var poly = turf.polygon([
[
[-81, 41],
[-81, 47],
[-72, 47],
[-72, 41],
[-81, 41],
],
]);
turf.booleanPointInPolygon(pt, poly);
//= true
安装
¥Installation
$ npm install @turf/boolean-point-in-polygon
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
const result = booleanPointInPolygon(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.booleanPointInPolygon(...);