Skip to main content
Version: Next

nearestPointToLine

描述

¥Description

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

名称类型描述
pointsFeatureCollection | GeometryCollection<>点集合
line特性 | 几何图形<LineString>线要素
options?对象可选参数(默认
options.units?stringunit of the output distance property (eg: degrees, radians, miles, or kilometers) (default 'kilometers')
options.properties?对象Translate Properties to Point (default )

返回

¥Returns

特性<> 最近点

¥Feature<Point> the closest point

示例

¥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(...);