Skip to main content
Version: Next

booleanPointInPolygon

描述

¥Description

Takes a and a 多边形 or MultiPolygon and determines if the point resides inside the polygon.The polygon can be convex or concave.The function accounts for holes.

¥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?booleanTrue if polygon boundary should be ignored when determining if the point is inside the polygon otherwise false.(默认 false)

返回

¥Returns

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