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
I have an application where given an linestring i need a part (slice) of it, from the beginning to some point. Ultimately I need the distance of the slice of the line. However, there are points that do not work. Both nearestPointOnLine and lineSlice are failing. I show
Below is an example along with the results.
let v_cs_ls_p1 = [-64.371054, 25.604782];
let v_cs_ls_p2 = [-19.65732, 45.178866];
let v_cs_ls = turf.lineString([v_cs_ls_p1, v_cs_ls_p2]);
let v_point_on_line = [-58.26491343728603, 28.5528852825411];
let v_point_on_line_adjusted = turf.nearestPointOnLine(v_cs_ls, v_point_on_line, { units: 'meters' });
v_point_on_line is on the line, but I call nearestPointOnLine anyway and it returns
as you can see, it thinks the distance is 687546 meters from the line and returns the point which it believes is the nearest which, in this case, is the start point of the line.
The distance should almost be zero (0) if not zero.
to me this seems like a problem, if this is my mistake then fine. Please show me.
update: i ran several other tests and this only appears to happen on really long lines. Long is subjective I know, but long in this case maybe mean earth factors in. Not sure.
The text was updated successfully, but these errors were encountered:
Hi @xobjects. Realise it's been a while since you reported this, though in case it's still of interest, I have some comments and some news.
v_point_on_line is on the line
First issue, this is on a line, though not the one Turf is using. That point looks ok projected on a 2D map. When tracing that line on a 3D globe though it looks more like the red line below:
but I call nearestPointOnLine anyway and it returns ... 687546 ... the start point of the line
All that said, nearestPointOnLine wasn't doing the 3D calculation correctly with the red line either. The closest point to v_point_on_line on the great circle line is at [ -59.06380751636502, 29.452900049382293 ] and about 675817m away. That's the red point on the map below:
A fix for the nearestPointOnLine issue is on its way. If you still have an interest in this, can you please elaborate a bit more on the lineSlice issues you were having? Some flow on changes to lineSlice are coming too, so it would be good to make sure they address any issues you had in that regard as well.
turf version: 6.5.0
I have an application where given an linestring i need a part (slice) of it, from the beginning to some point. Ultimately I need the distance of the slice of the line. However, there are points that do not work. Both nearestPointOnLine and lineSlice are failing. I show
Below is an example along with the results.
v_point_on_line is on the line, but I call nearestPointOnLine anyway and it returns
as you can see, it thinks the distance is 687546 meters from the line and returns the point which it believes is the nearest which, in this case, is the start point of the line.
The distance should almost be zero (0) if not zero.
to me this seems like a problem, if this is my mistake then fine. Please show me.
update: i ran several other tests and this only appears to happen on really long lines. Long is subjective I know, but long in this case maybe mean earth factors in. Not sure.
The text was updated successfully, but these errors were encountered: