# 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.
返回点和线段之间的最小距离。
> npm install @turf/point-to-line-distance
参数
参数 | 类型 | 描述 |
---|---|---|
pt | Coord | Feature 或 Geometry |
line | Feature <LineString> | GeoJSON Feature或Geometry |
options | Object | 可选参数:见下文 |
options选项
属性 | 类型 | 默认值 | 描述 |
---|---|---|---|
units | string | 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