You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @returns {Feature<Point>} closest point on the `line` to `point`. The properties object will contain four values: `index`: closest point was found on nth line part, `multiFeatureIndex`: closest point was found on the nth line of the `MultiLineString`, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point, `multiFeatureLocation`: distance along the line between start of the `MultiLineString` where closest point was found and the closest point.
25
+
* @returns {Feature<Point>} closest point on the `lines` to the `inputPoint`. The point will have the following properties: `lineStringIndex`: closest point was found on the nth LineString (only relevant if input is MultiLineString), `segmentIndex`: closest point was found on nth line segment of the LineString, `totalDistance`: distance along the line from the absolute start of the MultiLineString, `lineDistance`: distance along the line from the start of the LineString where the closest point was found, `segmentDistance`: distance along the line from the start of the line segment where the closest point was found, `pointDistance`: distance to the input point.
26
26
* @example
27
27
* var line = turf.lineString([
28
28
* [-77.031669, 38.878605],
@@ -47,11 +47,12 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
47
47
): Feature<
48
48
Point,
49
49
{
50
-
dist: number;
51
-
index: number;
52
-
multiFeatureIndex: number;
53
-
location: number;
54
-
multiFeatureLocation: number;
50
+
lineStringIndex: number;
51
+
segmentIndex: number;
52
+
totalDistance: number;
53
+
lineDistance: number;
54
+
segmentDistance: number;
55
+
pointDistance: number;
55
56
[key: string]: any;
56
57
}
57
58
>{
@@ -61,21 +62,13 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
61
62
62
63
constinputPos=getCoord(inputPoint);
63
64
64
-
letclosestPt: Feature<
65
-
Point,
66
-
{
67
-
dist: number;
68
-
index: number;
69
-
multiFeatureIndex: number;
70
-
location: number;
71
-
multiFeatureLocation: number;
72
-
}
73
-
>=point([Infinity,Infinity],{
74
-
dist: Infinity,
75
-
index: -1,
76
-
multiFeatureIndex: -1,
77
-
location: -1,
78
-
multiFeatureLocation: -1,
65
+
letclosestPt=point([Infinity,Infinity],{
66
+
lineStringIndex: -1,
67
+
segmentIndex: -1,
68
+
totalDistance: -1,
69
+
lineDistance: -1,
70
+
segmentDistance: -1,
71
+
pointDistance: Infinity,
79
72
});
80
73
81
74
letlength=0.0;
@@ -122,24 +115,20 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
0 commit comments