计算点到线段的距离(pointToLineDistance)
js
npm install @turf/point-to-line-distance
计算一个点和一条LineString之间的最小距离,即点和LineString的任何线段之间的最小距离。
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.
参数
参数 | 类型 | 描述 |
---|---|---|
pt | (Feature <Point>/Array ) | Feature or Geometry |
line | Feature <LineString> | GeoJSON Feature or Geometry |
options | Object | 配置项 |
配置项(Options)
Prop | 类型 | 默认值 | 描述 |
---|---|---|---|
units | string | kilometers | 你可以选择:degrees(角度) radians(弧度) miles(英里) 或者 kilometers(千米) |
method | string | geodesic | 是用测地线(球面)法计算距离还是用平面(平面)法计算距离。可选:geodesic 、planar |
返回(Returns)
number
- 点与线之间的距离
示例