# nearestPoint

Takes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference. This calculation is geodesic.
取一个参考点和一个具有点几何特征的FeatureCollection,并从FeatureCollection返回最接近的参考点的点。此计算是测地线计算。

参数

参数 类型 描述
targetPoint Coord 参考点
points FeatureCollection <Point> 点集合

返回

Feature <Point> - 集合中与参考点最接近的点

示例

var targetPoint = turf.point([112.015826, 36.074031], {"marker-color": "#F00"});
var points = turf.featureCollection([
    turf.point([105.142483, 35.834725]),
    turf.point([104.772949, 30.963027]),
    turf.point([110.907223, 33.09316])
]);

var nearest = turf.nearestPoint(targetPoint, points);
npm install @turf/nearest-point
Last Updated: 6/23/2023, 10:33:35 PM