# booleanPointInPolygon

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.
取一个点和一个多边形或多边形集合,并判断该点是否位于该多边形内部(多边形可以是凸多边形或凹多边形)。

> npm install @turf/boolean-point-in-polygon

参数

参数 类型 描述
point Coord 输入点
polygon Feature <(Polygon|MultiPolygon)> 多边形或多边形集合
options Object 可选参数:见下文

options选项

属性 类型 默认值 描述
ignoreBoundary boolean false 是否忽略多边形边界

返回

boolean - 如果点在多边形内,则返回true,否则返回false

示例

var pt = turf.point([-77, 44]);
var poly = turf.polygon([[
  [-81, 41], // 注意:polygon首尾坐标要一致
  [-81, 47],
  [-72, 47],
  [-72, 41],
  [-81, 41]
]]);

turf.booleanPointInPolygon(pt, poly);
//= true
Last Updated: 6/23/2023, 10:33:35 PM