Given a LineString like this, with one endpoint in the North Atlantic ocean and one in the South Pacific:
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-96.80974, -58.32062],
[-50.2464, 38.36643]
]
}
}
and a target Point like this, in Europe,
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [13.6023, 46.50646]
}
}
the nearestPointOnLine function should return [-50.2464, 38.36643], the segment endpoint in the North Atlantic ocean, as it is much closer than the other endpoint (5173km vs 15348km), and no other point on the segment is closer.
However, instead, turf returns a point very close to (withing floating-point-precision error of) the South Pacific endpoint.