Skip to content

KBE3D / KBCore / turf / nearestPointToLine

函数: nearestPointToLine()

nearestPointToLine<P>(points: GeometryCollection<Geometry> | FeatureCollection<Point, GeoJsonProperties> | Feature<GeometryCollection<Geometry>, GeoJsonProperties>, line: LineString | Feature<LineString, GeoJsonProperties>, options?: { units?: Units; properties?: GeoJsonProperties; }): Feature<Point, P>

Function

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.

类型参数

P

P = {[key: string]: any; dist: number; }

参数

points

Point Collection

GeometryCollection<Geometry> | FeatureCollection<Point, GeoJsonProperties> | Feature<GeometryCollection<Geometry>, GeoJsonProperties>

line

Line Feature

LineString | Feature<LineString, GeoJsonProperties>

options?

Optional parameters

units?

Units

unit of the output distance property. Supports all valid Turf Units

. (eg: degrees, radians, miles, or kilometers)

properties?

GeoJsonProperties

Translate Properties to Point

返回

Feature<Point, P>

the closest point

示例

ts
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);

//addToMap
var addToMap = [nearest, line];

KBE3D @3.0.0 Copyright © 2024-present KBE3D