-
Notifications
You must be signed in to change notification settings - Fork 951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lineIntersect returns the same point several times #688
Comments
Gday @grundid Thanks for the report, that does seem to be an unexpected output! I think we can mark this as a bug, it should be fairly easy to remove duplicate pairs of output coordinates. |
Agreed, this is a bug, I can definitely have a look at this. |
Thanks for looking into it. Unfortunately the problem is also visible in other functions like lineSplit. When I split a line like this: const point = turf.point([8, 50]);
const line1 = turf.lineString([[7, 50], [8, 50], [9, 50]]);
const splitLines = turf.lineSplit(line1, point); I receive two lines, which is correct, but the second line contains the splitter point twice. line[0]: { type: 'LineString', coordinates: [ [ 7, 50 ], [ 8, 50 ] ] }
line[1]: { type: 'LineString', coordinates: [ [ 8, 50 ], [ 8, 50 ], [ 9, 50 ] ] } Wherever listSegment is used to split the line into 2-vertex lines one would have to rethink the algorithm, I guess. |
Once |
I'm sorry, but the splitLineWithPoint function in the line-split module doesn't use lineIntersect. I guess, a simple fix for the splitLineWithPoint function might be to check if the initialValue (or getCoords(segments.features[0])[0]) in line 143 equals to the coords in line 148 and then don't add it to the returning array in line 151. I haven't tested it though ;) |
👍 Oh that's true, I assumed it was since the Feel free to send a PR with a fix, we can hash out any details in the PR. |
Fixed in next minor release. |
I'm trying to find out the point at which two lines intersect. The two lines have the intersecting point in common like:
In this case lineIntersect returns the point [8, 50] 4 times. By looking at the implementation the problem is obvious since the given lines are split into 2-vertex lines and then the intersections are calculated.
I'm not sure if you want to fix this, but it would be nice if the documentation would explain this scenario.
The text was updated successfully, but these errors were encountered: