# pointToLineDistance

Returns the minimum distance between a Point and a LineString , being the distance from a line the minimum distance between the point and any segment of the LineString.
计算点与LineString任何段之间的最小距离。

> npm install @turf/point-to-line-distance

参数

参数 类型 描述
pt Coord Feature or Geometry
line Feature <LineString> GeoJSON Feature or Geometry
options Object Optional parameters: see below

options选项

属性 类型 默认值 描述
units string kilometers can be degrees, radians, miles, or kilometers
mercator boolean false if distance should be on Mercator or WGS84 projection

返回

number - distance between point and line

示例

var pt = turf.point([0, 0]);
var line = turf.lineString([[1, 1],[-1, 1]]);

var distance = turf.pointToLineDistance(pt, line, {units: 'miles'});
//=69.11854715938406
Last Updated: 1/19/2021, 10:59:20 AM