Skip to main content
Version: 7.2.0

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(...);