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
greatCircle returns array of NaN if start and end is the same #2342
Comments
Thanks for the bug report @laurenceks - it sounds like a more valid output would be a linestring with duplicated first and last coords. |
One question @laurenceks - do you think the resulting line should have two coords, or should it have
At this stage I'm leaning towards the first, and adding the following to the documentation
|
My instinct is actually to match npoints as personally I would expect greatCircle to always give a consistent array length, even if it's an array of 100 duplicates. Whilst the shorter line string would work for my use case, there might be scenarios where someone's code is expecting an array of the same length (npoints) every time. The issue at hand isn't the array length but the contents of the array. If greatCircle returned an array of 100 duplicates I think that would still plot fine on a map; it's the output of NaN causing the problem. I think anyone wanting to remove duplicates could use cleanCoords? That being said I'm just an amateur and don't really have a strong opinion! My broad understanding is consistency is usually better with function returns but so long as it outputs a valid line string my issue would be fixed. Ps thanks for picking this up quickly! |
Awesome - having slept on it I think I agree with you @laurenceks so I've updated the PR. |
Any update on this? |
@turf/great-circle 6.5.0
If the coordinates passed to
greatCircle
are the same it returns an array of NaNs.This has happened during a line animation along a
greatCricle
. The animation draws a line up to the progress marker so that the line is divided in colour to show progress. Effectively the initial completegreatCircle
line is being painted over by the same line (this is inmapbox-gl
).As the progress percentage in the first frame is 0% the coordinates passed to
greatCricle
are the same for start and end points.greatCricle
returns a linestring with coordinates of[[NaN, NaN], [NaN, NaN]...]
, which cannot be used and cause an error.Expected output would be an array of all coordinates the same (the start point).
Example
This does not work when
coordinates.start.arrayLongLat
andprogressMarkerCoordinates
are equal:Comparing the start and end and substituing a simple linestring if they are the same prevents this issue, but I feel shouldn't be necessary
Code context
Is this intended behaviour or a genuine issue?
(Similar old issues #1361 #1946 with lineOffset, ?related)
The text was updated successfully, but these errors were encountered: