Skip to main content
Version: 7.2.0

pointToPolygonDistance

描述

¥Description

计算从一个点到一个多边形或多个多边形边的距离。返回多边形内点的负值。处理带孔的多边形和多个多边形。洞被视为多边形的外部。

¥Calculates the distance from a point to the edges of a polygon or multi-polygon. Returns negative values for points inside the polygon. Handles polygons with holes and multi-polygons. A hole is treated as the exterior of the polygon.

参数

¥Parameters

名称类型描述
point特性<> | | 位置输入点
polygonOrMultiPolygon特性<多边形 | MultiPolygon> | 多边形 | MultiPolygon输入多边形或多多边形
options对象可选参数(默认 {})
options.units单位结果单位,例如 "kilometers"、"miles"、"meters"
options.method"geodesic" | "planar"结果方法

返回

¥Returns

number 距离(以米为单位)(多边形内部的点为负值)

¥number Distance in meters (negative values for points inside the polygon)

安装

¥Installation

$ npm install @turf/point-to-polygon-distance

import { pointToPolygonDistance } from "@turf/point-to-polygon-distance";
const result = pointToPolygonDistance(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.pointToPolygonDistance(...);