Skip to content
5 changes: 5 additions & 0 deletions packages/turf-nearest-point-on-line/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "7.2.0",
"description": "Finds the nearest point on a line to a given point",
"author": "Turf Authors",
"contributors": [
"Angel Lacret <@alacret>",
"Jon Miles <@jonmiles>",
"John Ziebro <@Insighttful>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
Expand Down
14 changes: 14 additions & 0 deletions packages/turf-nearest-point-on-line/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,17 @@ test("turf-nearest-point-on-line -- issue 2808 redundant point support", (t) =>

t.end();
});

test("turf-nearest-point-on-line -- duplicate points on line string shouldn't break the function.", (t) => {
// @jonmiles
const line = lineString([
[-80.191793, 25.885611],
[-80.191793, 25.885611],
[-80.191543, 25.885874],
]);
const userPoint = point([-80.191762, 25.885587]);
const nearest = nearestPointOnLine(line, userPoint, { units: "meters" });
t.equal(nearest.properties.dist > 4, true, "dist should be greater than 4");
t.equal(nearest.properties.location, 0, "location should be 0");
t.end();
});