Skip to content
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

Cleancoords on edge case lineString results in 'invalid polygon' error #2305

Open
plarner30 opened this issue Jun 28, 2022 · 2 comments
Open

Comments

@plarner30
Copy link

Turf 6.5.0

turf.cleanCoords(turf.lineString([[0, 0], [0, 1], [0, 0]])) causes an invalid polygon error to occur though interestingly turf.lineString([[0, 0], [0, 1], [0, 0]]) is just fine.

Expecting the output to be {"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[0,0],[0,1]]}} as there is no point in a lineString which goes to a location and returns on exactly the same path?

Another example that can trigger the invalid polygon error: turf.cleanCoords(turf.lineString([[0, 0], [0, 0], [0, 2], [0,2], [0, 0]]))

@stebogit stebogit added the bug label Jun 28, 2022
@benoitbzl
Copy link

Hi. I am facing the same issue. The code of cleanCoords has been fixed in august 2021, but [email protected] has been generated in july 2021. Is there a plan to generate a new version of turf that would include this fixed code?

@smallsaucepan
Copy link
Member

@benoitbzl in case you weren't aware 7.1.0 of turf has been released. From your comment above the "invalid polygon" error sounds like it will have been fixed in that release.

Expecting the output to be {"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[0,0],[0,1]]}} as there is no point in a lineString which goes to a location and returns on exactly the same path?

Not quite true @plarner30. A lineString that goes both directions is twice as long for starters, so can't really be considered the same.

Once the PR to close #2740 is merged will close this as well, as all the test cases listed should then work consistently.

@smallsaucepan smallsaucepan removed the bug label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants