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

LineOffset is crashing with two identical coordinates in sequence #1946

Open
SelaO opened this issue Sep 21, 2020 · 4 comments
Open

LineOffset is crashing with two identical coordinates in sequence #1946

SelaO opened this issue Sep 21, 2020 · 4 comments

Comments

@SelaO
Copy link

SelaO commented Sep 21, 2020

I'm getting the error:

catch, Error: coordinates must contain numbers

when there are two or more identical coordinates in sequence:

          const arr1 = [[1,1], [1,1]]
          const x = lineString(arr1)
          const y = lineOffset(x, 0.001)

but this works:

          const arr1 = [[1,1],[12,12], [1,1]]
          const x = lineString(arr1)
          const y = lineOffset(x, 0.001)

It isn't mentioned in the docs that it's not ok to have identical points...

@stebogit
Copy link
Collaborator

Yeah, and the GeoJSON specs don't require LineString to include different positions. So I guess an error should not be thrown.

@SelaO SelaO changed the title LineOffset is crashing with two identical coordinates LineOffset is crashing with two identical coordinates in sequence Sep 21, 2020
@SelaO
Copy link
Author

SelaO commented Sep 21, 2020

This bug is with lineOffset not LineString @stebogit

@stebogit
Copy link
Collaborator

Sure, but I checked that to make sure that an error was not actually ok. What I mean is that if a valid LineString was actually required to have different positions, than an error thrown by lineOffset on an invalid input would not have been considered wrong, or a bug.

@mfedderly
Copy link
Collaborator

This isn't throwing an error any more, but it does return a bunch of NaN's that aren't helpful. This seems to root down to the processSegment method which calculates L to be 0 which gives us the NaN values.

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

3 participants