Skip to main content
Version: 7.3.0

booleanPointInPolygon

描述

🌐 Description

接受一个和一个多边形多多边形,并确定该点是否位于多边形内。多边形可以是凸的或凹的。该函数会考虑孔洞。

🌐 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

名称类型描述
pointCoord输入点
polygonFeature<Polygon | MultiPolygon>输入多边形或多多边形
options?Object可选参数 (默认 {})
options.ignoreBoundary?boolean如果在确定点是否在多边形内时应忽略多边形边界,则为真,否则为假。(默认 false)

返回

🌐 Returns

boolean 如果点在多边形内,则为true;如果点不在多边形内,则为false

示例

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