nearestPointToLine
描述
🌐 Description
返回 collection 中最接近 line 的 point。返回的点具有一个 dist 属性,表示它到直线的距离。
🌐 Returns the closest point, of a collection of points,
to a line. The returned point has a dist property indicating its distance to the line.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| points | FeatureCollection | GeometryCollection<Point> | 积分收集 |
| line | Feature | Geometry<LineString> | 线特性 |
| options? | Object | 可选参数 (默认 {}) |
| options.units? | Units | 输出距离属性的单位。支持所有有效的 Turf 单位。(例如:度数、弧度、英里或公里)(默认 '公里') |
| options.properties? | Object | 将属性转换为点 (默认 {}) |
返回
🌐 Returns
示例
🌐 Examples
var pt1 = turf.point([0, 0]);
var pt2 = turf.point([0.5, 0.5]);
var points = turf.featureCollection([pt1, pt2]);
var line = turf.lineString([
[1, 1],
[-1, 1],
]);
var nearest = turf.nearestPointToLine(points, line);
安装
🌐 Installation
$ npm install @turf/nearest-point-to-line
import { nearestPointToLine } from "@turf/nearest-point-to-line";
const result = nearestPointToLine(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.nearestPointToLine(...);