Skip to content

Commit bac370a

Browse files
@turf/nearest-point-on-line TESTS: add test for duplicated points on line string affecting v7.2.0 (#2903)
* TESTS: add test for duplicated points on line string affecting v7.2.0 --------- Co-authored-by: James Beard <[email protected]>
1 parent 736b1ef commit bac370a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/turf-nearest-point-on-line/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"version": "7.2.0",
44
"description": "Finds the nearest point on a line to a given point",
55
"author": "Turf Authors",
6+
"contributors": [
7+
"Angel Lacret <@alacret>",
8+
"Jon Miles <@jonmiles>",
9+
"John Ziebro <@Insighttful>"
10+
],
611
"license": "MIT",
712
"bugs": {
813
"url": "https://github.com/Turfjs/turf/issues"

packages/turf-nearest-point-on-line/test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,20 @@ test("turf-nearest-point-on-line -- issue 2808 redundant point support", (t) =>
519519
t.end();
520520
});
521521

522+
test("turf-nearest-point-on-line -- duplicate points on line string shouldn't break the function.", (t) => {
523+
// @jonmiles
524+
const line = lineString([
525+
[-80.191793, 25.885611],
526+
[-80.191793, 25.885611],
527+
[-80.191543, 25.885874],
528+
]);
529+
const userPoint = point([-80.191762, 25.885587]);
530+
const nearest = nearestPointOnLine(line, userPoint, { units: "meters" });
531+
t.equal(nearest.properties.dist > 4, true, "dist should be greater than 4");
532+
t.equal(nearest.properties.location, 0, "location should be 0");
533+
t.end();
534+
});
535+
522536
test("turf-nearest-point-on-line -- issue 2934 correct endpoint chosen when in opposite hemisphere", (t) => {
523537
// create a long line where the southern end point should be chosen, but the
524538
// northern endpoint is closer to the projected great circles

0 commit comments

Comments
 (0)